class_docstr: Class that validates and converts other data types to Transition.
  
  Note that validation and conversion allows values to contain dictionaries
  with extra keys as compared to the specs in the data context.  These
  additional entries / observations are ignored and dropped during conversion.
  
  This non-strict checking allows users to provide additional info and
  observation keys at input without having to manually prune them before
  converting.
class_docstr_tok: ["Class","that","validates","and","converts","other","data","types","to","Transition",".","Note","that","validation","and","conversion","allows","values","to","contain","dictionaries","with","extra","keys","as","compared","to","the","specs","in","the","data","context",".","These","additional","entries","\/","observations","are","ignored","and","dropped","during","conversion",".","This","non-strict","checking","allows","users","to","provide","additional","info","and","observation","keys","at","input","without","having","to","manually","prune","them","before","converting","."]
docstr: Converts `value` to a Transition. Performs data validation and pruning.
  
  - If `value` is already a `Transition`, only validation is performed.
  - If `value` is a `Trajectory` and `squeeze_time_dim = True` then
    `value` it must have tensors with shape `[B, T=2]` outer dims.
    This is converted to a `Transition` object without a time
    dimension.
  - If `value` is a `Trajectory` with tensors containing a time dimension
    having `T != 2`, a `ValueError` is raised.
  
  Args:
    value: A `Trajectory` or `Transition` object to convert.
  
  Returns:
    A validated and pruned `Transition`.  If `squeeze_time_dim = True`,
    the resulting `Transition` has tensors with shape `[B, ...]`.  Otherwise,
    the tensors will have shape `[B, T - 1, ...]`.
  
  Raises:
    TypeError: If `value` is not one of `Trajectory` or `Transition`.
    ValueError: If `value` has structure that doesn't match the converter's
      spec.
    TypeError: If `value` has a structure that doesn't match the converter's
      spec.
    ValueError: If `squeeze_time_dim=True` and `value` is a `Trajectory`
      with a time dimension having value other than `T=2`.
code: def __call__(self, value: typing.Any) -> trajectory.Transition:
      """Converts `value` to a Transition. Performs data validation and pruning.
  
      - If `value` is already a `Transition`, only validation is performed.
      - If `value` is a `Trajectory` and `squeeze_time_dim = True` then
        `value` it must have tensors with shape `[B, T=2]` outer dims.
        This is converted to a `Transition` object without a time
        dimension.
      - If `value` is a `Trajectory` with tensors containing a time dimension
        having `T != 2`, a `ValueError` is raised.
  
      Args:
        value: A `Trajectory` or `Transition` object to convert.
  
      Returns:
        A validated and pruned `Transition`.  If `squeeze_time_dim = True`,
        the resulting `Transition` has tensors with shape `[B, ...]`.  Otherwise,
        the tensors will have shape `[B, T - 1, ...]`.
  
      Raises:
        TypeError: If `value` is not one of `Trajectory` or `Transition`.
        ValueError: If `value` has structure that doesn't match the converter's
          spec.
        TypeError: If `value` has a structure that doesn't match the converter's
          spec.
        ValueError: If `squeeze_time_dim=True` and `value` is a `Trajectory`
          with a time dimension having value other than `T=2`.
      """
      if _is_transition_like(value):
          value = _as_tfa_transition(value)
      elif _is_trajectory_like(value):
          required_sequence_length = (
              2 if self._squeeze_time_dim else None
          )
          _validate_trajectory(
              value,
              self._data_context.trajectory_spec,
              sequence_length=required_sequence_length,
          )
          value = trajectory.to_transition(value)
          # Remove the now-singleton time dim.
          if self._squeeze_time_dim:
              value = tf.nest.map_structure(
                  lambda x: composite.squeeze(x, axis=1), value
              )
      else:
          raise TypeError("Input type not supported: {}".format(value))
  
      num_outer_dims = 1 if self._squeeze_time_dim else 2
      _validate_transition(
          value, self._data_context.transition_spec, num_outer_dims
      )
  
      value = nest_utils.prune_extra_keys(
          self._data_context.transition_spec, value
      )
  
      if self._prepend_t0_to_next_time_step:
          # This is useful when using sequential model. It allows target_q network
          # to take all the information.
          next_time_step_with_t0 = value.next_time_step._replace(
              observation=tf.nest.map_structure(
                  lambda x, y: tf.concat([x[:, :1, ...], y], axis=1),
                  value.time_step.observation,
                  value.next_time_step.observation,
              )
          )
  
          value = value._replace(next_time_step=next_time_step_with_t0)
      return value
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import typing
  import tensorflow
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import policy_step
  from tf_agents.trajectories import time_step
  from tf_agents.trajectories import trajectory
  from tf_agents.typing import types
  from tf_agents.utils import composite
  from tf_agents.utils import nest_utils
  import typing_extensions
label_desc: Use image node_id 2 for calling the AsTransition obj's underlying member method code with example usage: obj.__call__(value) and returns: value