class_docstr: Randomly generates observations following the given observation_spec.
  
  If an action_spec is provided, it validates that the actions used to step the
  environment are compatible with the given spec.
class_docstr_tok: ["Randomly","generates","observations","following","the","given","observation_spec",".","If","an","action_spec","is","provided",",","it","validates","that","the","actions","used","to","step","the","environment","are","compatible","with","the","given","spec","."]
docstr: Initializes the environment.
  
  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.
    episode_end_probability: Probability an episode will end when the
      environment is stepped.
docstr_tok: ["Initializes","the","environment",".","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",".","episode_end_probability",":","Probability","an","episode","will","end","when","the","environment","is","stepped","."]
code: def __init__(
      self,
      time_step_spec,
      action_spec,
      batch_size=1,
      episode_end_probability=0.1,
  ):
      """Initializes the environment.
  
      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.
        episode_end_probability: Probability an episode will end when the
          environment is stepped.
      """
      super(RandomTFEnvironment, self).__init__(
          time_step_spec, action_spec, batch_size=batch_size
      )
      self._episode_end_probability = episode_end_probability
  
      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
      )
  
file_path: agents/tf_agents/environments/random_tf_environment.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import tensorflow
  from tf_agents.environments import tf_environment
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import time_step
  from tf_agents.utils import common
  from tf_agents.utils import nest_utils
label_desc: Use image node_id 1 to create a new RandomTFEnvironment object from inherited base classes: tf_environment with example: obj = RandomTFEnvironment(time_step_spec, action_spec, batch_size, episode_end_probability)