code: def from_transition(
      time_step: ts.TimeStep,
      action_step: policy_step.PolicyStep,
      next_time_step: ts.TimeStep,
  ) -> Trajectory:
      """Returns a `Trajectory` given transitions.
  
      `from_transition` is used by a driver to convert sequence of transitions into
      a `Trajectory` for efficient storage. Then an agent (e.g.
      `ppo_agent.PPOAgent`) converts it back to transitions by invoking
      `to_transition`.
  
      Note that this method does not add a time dimension to the Tensors in the
      resulting `Trajectory`. This means that if your transitions don't already
      include a time dimension, the `Trajectory` cannot be passed to
      `agent.train()`.
  
      Args:
        time_step: A `time_step.TimeStep` representing the first step in a
          transition.
        action_step: A `policy_step.PolicyStep` representing actions corresponding
          to observations from time_step.
        next_time_step: A `time_step.TimeStep` representing the second step in a
          transition.
      """
      return Trajectory(
          step_type=time_step.step_type,
          observation=time_step.observation,
          action=action_step.action,
          policy_info=action_step.info,
          next_step_type=next_time_step.step_type,
          reward=next_time_step.reward,
          discount=next_time_step.discount,
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  import pprint
  from typing import NamedTuple, Optional
  import numpy
  import tensorflow
  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 composite
  from tf_agents.utils import nest_utils
  from tf_agents.utils import value_ops
label_desc: Use image node_id 9 for calling a global function with example usage: from_transition(time_step, action_step, next_time_step) and returns: Trajectory