def METHOD_NAME(
    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,
    )