class_docstr: Returns random samples of the given action_spec.
class_docstr_tok: ["Returns","random","samples","of","the","given","action_spec","."]
code: def _action(
      self, time_step, policy_state, seed: Optional[types.Seed] = None
  ):
      del seed  # Unused. Seed passed to the class.
      outer_dims = self._outer_dims
      if outer_dims is None:
          if self.time_step_spec.observation:
              outer_dims = nest_utils.get_outer_array_shape(
                  time_step.observation, self.time_step_spec.observation
              )
          else:
              outer_dims = ()
  
      observation_and_action_constraint_splitter = (
          self.observation_and_action_constraint_splitter
      )
  
      if observation_and_action_constraint_splitter is not None:
          _, mask = observation_and_action_constraint_splitter(
              time_step.observation
          )
  
          zero_logits = tf.cast(tf.zeros_like(mask), tf.float32)
          masked_categorical = masked.MaskedCategorical(
              zero_logits, mask
          )
          random_action = tf.cast(
              masked_categorical.sample() + self.action_spec.minimum,
              self.action_spec.dtype,
          )
  
          # If the action spec says each action should be shaped (1,), add another
          # dimension so the final shape is (B, 1) rather than (B,).
          if len(self.action_spec.shape) == 1:
              random_action = tf.expand_dims(random_action, axis=-1)
      else:
          random_action = array_spec.sample_spec_nest(
              self._action_spec, self._rng, outer_dims=outer_dims
          )
  
      info = array_spec.sample_spec_nest(
          self._info_spec, self._rng, outer_dims=outer_dims
      )
  
      return policy_step.PolicyStep(random_action, policy_state, info)
  
file_path: agents/tf_agents/policies/random_py_policy.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Optional, Sequence
  import numpy
  import tensorflow
  from tf_agents.distributions import masked
  from tf_agents.policies import py_policy
  from tf_agents.specs import array_spec
  from tf_agents.trajectories import policy_step
  from tf_agents.trajectories import time_step
  from tf_agents.typing import types
  from tf_agents.utils import nest_utils
label_desc: Use image node_id 2 for calling the RandomPyPolicy obj's underlying member method code with example usage: obj._action(time_step, policy_state, seed) and returns: policy_step