def remove_exceeding_samples(states_accumulator,
                             policy_accumulator,
                             value_prior_accumulator,
                             max_samples_per_result_to_train):
    """ Remove older samples when they exceed the maximum number of samples
    to keep.

    Args:
      states_accumulator: np.array NCHW: a tensor with all the collected
        states.
      policy_accumulator: np.array: a vector with all the collected policy
        labels.
      value_prior_accumulator: np.array: a vector with all the collected value
        labels.
      max_samples_per_result_to_train: int: number of maximum samples to keep
        per result type.

    Returns:
      np.array NCHW: the states without exceeding samples
      np.array: the policies without exceeding samples
      np.array: the values without exceeding samples
    """
    for ires in range(len(states_accumulator)):
        if len(states_accumulator[ires]) > \
                max_samples_per_result_to_train:
            diff = len(states_accumulator[ires]) - \
                max_samples_per_result_to_train
            states_accumulator[ires] = \
                states_accumulator[ires][diff:]
            policy_accumulator[ires] = \
                policy_accumulator[ires][diff:]
            value_prior_accumulator[ires] = \
                value_prior_accumulator[ires][diff:]
    return states_accumulator, policy_accumulator, value_prior_accumulator