def _n_slices(trajectory, max_slice_length, margin):
  """How many slices of length upto max_slice_length in a trajectory."""
  # TODO(lukaszkaiser): add option to sample from n last trajectories.
  if not max_slice_length:
    return 1
  # A trajectory [a, b, c, end_state] will have 2 slices of length 2:
  # the slice [a, b] and the one [b, c], with margin=0; 3 with margin=1.
  return max(1, len(trajectory) + margin - max_slice_length)
How many slices of length upto max_slice_length in a trajectory.
trax/rl/task.py