class_docstr: Base class for bandit environments implemented in TensorFlow.
  
  Subclasses should implement the `_apply_action` and `_observe` methods.
  
  Example usage with eager mode:
  ```
    # reset() creates the initial time_step and resets the environment.
    time_step = environment.reset()
    for _ in tf.range(num_steps):
      action_step = policy.action(time_step)
      time_step = environment.step(action_step.action)
  ```
  
  Example usage with graph mode:
  ```
    # current_time_step() creates the initial TimeStep.
    time_step = environment.current_time_step()
    action_step = policy.action(time_step)
    # Apply the action and return the new TimeStep.
    next_time_step = environment.step(action_step.action)
  
    sess.run([time_step, action_step, next_time_step])
  ```
class_docstr_tok: ["Base","class","for","bandit","environments","implemented","in","TensorFlow",".","Subclasses","should","implement","the","`","_apply_action","`","and","`","_observe","`","methods",".","Example","usage","with","eager","mode",":","``","`","#","reset","(",")","creates","the","initial","time_step","and","resets","the","environment",".","time_step","=","environment.reset","(",")","for","_","in","tf.range","(","num_steps",")",":","action_step","=","policy.action","(","time_step",")","time_step","=","environment.step","(","action_step.action",")","``","`","Example","usage","with","graph","mode",":","``","`","#","current_time_step","(",")","creates","the","initial","TimeStep",".","time_step","=","environment.current_time_step","(",")","action_step","=","policy.action","(","time_step",")","#","Apply","the","action","and","return","the","new","TimeStep",".","next_time_step","=","environment.step","(","action_step.action",")","sess.run","(","[","time_step",",","action_step",",","next_time_step","]",")","``","`"]
docstr: Initialize instances of `BanditTFEnvironment`.
  
  Args:
    time_step_spec: A `TimeStep` namedtuple containing `TensorSpec`s defining
      the tensors returned by `step()` (step_type, reward, discount, and
      observation).
    action_spec: A nest of BoundedTensorSpec representing the actions of the
      environment.
    batch_size: The batch size expected for the actions and observations.
    name: The name of this environment instance.
docstr_tok: ["Initialize","instances","of","`","BanditTFEnvironment","`",".","Args",":","time_step_spec",":","A","`","TimeStep","`","namedtuple","containing","`","TensorSpec","`","s","defining","the","tensors","returned","by","`","step","(",")","`","(","step_type",",","reward",",","discount",",","and","observation",")",".","action_spec",":","A","nest","of","BoundedTensorSpec","representing","the","actions","of","the","environment",".","batch_size",":","The","batch","size","expected","for","the","actions","and","observations",".","name",":","The","name","of","this","environment","instance","."]
code: def __init__(
      self,
      time_step_spec: Optional[types.NestedArray] = None,
      action_spec: Optional[types.NestedArray] = None,
      batch_size: Optional[types.Int] = 1,
      name: Optional[Text] = None,
  ):
      """Initialize instances of `BanditTFEnvironment`.
  
      Args:
        time_step_spec: A `TimeStep` namedtuple containing `TensorSpec`s defining
          the tensors returned by `step()` (step_type, reward, discount, and
          observation).
        action_spec: A nest of BoundedTensorSpec representing the actions of the
          environment.
        batch_size: The batch size expected for the actions and observations.
        name: The name of this environment instance.
      """
      self._reset_called = tf.compat.v2.Variable(
          False, trainable=False, name="reset_called"
      )
  
      def _variable_from_spec(name, spec):
          full_shape = [batch_size] + spec.shape.as_list()
          if not name:
              name = "spec_var"
          return common.create_variable(
              name, 0, shape=full_shape, dtype=spec.dtype
          )
  
      paths_and_specs = nest_utils.flatten_with_joined_paths(
          time_step_spec
      )
      variables = [
          _variable_from_spec(path, spec)
          for path, spec in paths_and_specs
      ]
      self._time_step_variables = tf.nest.pack_sequence_as(
          time_step_spec, variables
      )
      self._name = name
  
      super(BanditTFEnvironment, self).__init__(
          time_step_spec=time_step_spec,
          action_spec=action_spec,
          batch_size=batch_size,
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import abc
  from typing import Optional, Text
  import six
  import tensorflow
  from tf_agents.environments import tf_environment
  from tf_agents.trajectories import time_step
  from tf_agents.typing import types
  from tf_agents.utils import common
  from tf_agents.utils import nest_utils
label_desc: Use image node_id 1 to create a new BanditTFEnvironment object from inherited base classes: tf_environment with example: obj = BanditTFEnvironment(time_step_spec, action_spec, batch_size, name)