class_docstr: A DQN Agent.
  
  Implements the DQN algorithm from
  
  "Human level control through deep reinforcement learning"
    Mnih et al., 2015
    https://deepmind.com/research/dqn/
  
  This agent also implements n-step updates. See "Rainbow: Combining
  Improvements in Deep Reinforcement Learning" by Hessel et al., 2017, for a
  discussion on its benefits: https://arxiv.org/abs/1710.02298
class_docstr_tok: ["A","DQN","Agent",".","Implements","the","DQN","algorithm","from","''","Human","level","control","through","deep","reinforcement","learning","''","Mnih","et","al.",",","2015","https",":","\/\/deepmind.com\/research\/dqn\/","This","agent","also","implements","n-step","updates",".","See","``","Rainbow",":","Combining","Improvements","in","Deep","Reinforcement","Learning","''","by","Hessel","et","al.",",","2017",",","for","a","discussion","on","its","benefits",":","https",":","\/\/arxiv.org\/abs\/1710.02298"]
code: def _check_action_spec(self, action_spec):
      flat_action_spec = tf.nest.flatten(action_spec)
  
      # TODO(oars): Get DQN working with more than one dim in the actions.
      if (
          len(flat_action_spec) > 1
          or flat_action_spec[0].shape.rank > 0
      ):
          raise ValueError(
              "Only scalar actions are supported now, but action spec is: {}".format(
                  action_spec
              )
          )
  
      spec = flat_action_spec[0]
  
      # TODO(b/119321125): Disable this once index_with_actions supports
      # negative-valued actions.
      if spec.minimum != 0:
          raise ValueError(
              "Action specs should have minimum of 0, but saw: {0}".format(
                  spec
              )
          )
  
      self._num_actions = spec.maximum - spec.minimum + 1
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  from typing import Optional, Text, cast
  import gin
  import tensorflow
  from tf_agents.agents import data_converter
  from tf_agents.agents import tf_agent
  from tf_agents.networks import network
  from tf_agents.networks import utils
  from tf_agents.policies import boltzmann_policy
  from tf_agents.policies import epsilon_greedy_policy
  from tf_agents.policies import greedy_policy
  from tf_agents.policies import q_policy
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import time_step
  from tf_agents.typing import types
  from tf_agents.utils import common
  from tf_agents.utils import eager_utils
  from tf_agents.utils import nest_utils
label_desc: Use image node_id 2 for calling the DqnAgent obj's underlying member method code with example usage: obj._check_action_spec(action_spec) without return types