Keras symbolic inputs/outputs do not implement `__len__`

def build_agent(model, actions):
# Boltzmann Q Policy builds a probability law on q values
# and returns an action selected randomly according to this law
policy = BoltzmannQPolicy()
# Sequential memory is used by the DQN agent to store various states, actions, and rewards
memory = SequentialMemory(limit=10000, window_length=1)
dqn = DQNAgent(model=model, memory=memory, policy=policy, <<<<<<<<<<<<<<<<<<<<<<<<<
nb_actions=actions, nb_steps_warmup=10, target_model_update=1e-2)
return dqn

At “<<<<”, error is " Exception has occurred: TypeError
Keras symbolic inputs/outputs do not implement __len__. You may be trying to pass Keras symbolic inputs/outputs to a TF API that does not register dispatching, preventing Keras from automatically converting the API call to a lambda layer in the Functional Model. This error will also get raised if you try asserting a symbolic input/output directly."


Can you please share the standalone code to replicate above issue?