code: def last(
      observation: types.NestedSpecTensorOrArray,
      action: types.NestedSpecTensorOrArray,
      policy_info: types.NestedSpecTensorOrArray,
      reward: types.NestedSpecTensorOrArray,
      discount: types.SpecTensorOrArray,
  ) -> Trajectory:
      """Create a Trajectory transitioning between StepTypes `MID` and `LAST`.
  
      All inputs may be batched.
  
      The input `discount` is used to infer the outer shape of the inputs,
      as it is always expected to be a singleton array with scalar inner shape.
  
      Args:
        observation: (possibly nested tuple of) `Tensor` or `np.ndarray`; all shaped
          `[B, ...]`, `[T, ...]`, or `[B, T, ...]`.
        action: (possibly nested tuple of) `Tensor` or `np.ndarray`; all shaped `[B,
          ...]`, `[T, ...]`, or `[B, T, ...]`.
        policy_info: (possibly nested tuple of) `Tensor` or `np.ndarray`; all shaped
          `[B, ...]`, `[T, ...]`, or `[B, T, ...]`.
        reward: (possibly nested tuple of) `Tensor` or `np.ndarray`; all shaped `[B,
          ...]`, `[T, ...]`, or `[B, T, ...]`.
        discount: A floating point vector `Tensor` or `np.ndarray`; shaped `[B]`,
          `[T]`, or `[B, T]` (optional).
  
      Returns:
        A `Trajectory` instance.
      """
      return _create_trajectory(
          observation,
          action,
          policy_info,
          reward,
          discount,
          name_scope="trajectory_last",
          step_type=ts.StepType.MID,
          next_step_type=ts.StepType.LAST,
      )
  
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 4 for calling a global function with example usage: last(observation, action, policy_info, reward, discount) and returns: _create_trajectory