code: def updated_sample(
      sample: Any,
      reward_shift: float,
      action_clipping: Optional[Tuple[float, float]],
      use_trajectories: bool,
  ):
      """Create a sample with reward_shift and action_clipping."""
  
      def _clip_actions(actions):
          return tf.clip_by_value(
              actions,
              clip_value_min=action_clipping[0],
              clip_value_max=action_clipping[1],
          )
  
      if use_trajectories:
          # Update trajectory.
          shifted_reward = sample.reward + reward_shift
          if action_clipping:
              return sample._replace(
                  action=tf.nest.map_structure(
                      _clip_actions, sample.action
                  ),
                  reward=shifted_reward,
              )
          else:
              return sample._replace(reward=shifted_reward)
      else:
          # Update transition.
          next_time_step = sample.next_time_step
          next_time_step = ts.TimeStep(
              step_type=next_time_step.step_type,
              reward=next_time_step.reward + reward_shift,
              discount=next_time_step.discount,
              observation=next_time_step.observation,
          )
          action_step = sample.action_step
          if action_clipping:
              action_step = action_step._replace(
                  action=tf.nest.map_structure(
                      _clip_actions, action_step.action
                  )
              )
          return trajectory.Transition(
              time_step=sample.time_step,
              action_step=action_step,
              next_time_step=next_time_step,
          )
  
file_path: agents/tf_agents/examples/cql_sac/kumar20/data_utils.py
imports: import functools
  from typing import Any, Callable, MutableSequence, Optional, Text, Tuple
  import numpy
  import tensorflow
  from tf_agents.trajectories import time_step
  from tf_agents.trajectories import trajectory
  from tf_agents.typing import types
  from tf_agents.utils import example_encoding
  from tf_agents.utils import example_encoding_dataset
label_desc: Use image node_id 1 for calling a global function with example usage: updated_sample(sample, reward_shift, action_clipping, use_trajectories) and returns: tf, trajectory, sample, sample