docstr: Make sure that the size of the replay buffer does not pass the maximum size allowed.
  If it passes the max size, the oldest transition in the replay buffer will be removed.
  This function does not use locks since it is only called internally
  :return: None
docstr_tok: ["Make","sure","that","the","size","of","the","replay","buffer","does","not","pass","the","maximum","size","allowed",".","If","it","passes","the","max","size",",","the","oldest","transition","in","the","replay","buffer","will","be","removed",".","This","function","does","not","use","locks","since","it","is","only","called","internally",":","return",":","None"]
code: def _enforce_max_length(self) -> None:
      """
      Make sure that the size of the replay buffer does not pass the maximum size allowed.
      If it passes the max size, the oldest transition in the replay buffer will be removed.
      This function does not use locks since it is only called internally
      :return: None
      """
      granularity, size = self.max_size
      if granularity == MemoryGranularity.Transitions:
          while size != 0 and self.num_transitions() > size:
              self._num_transitions -= 1
              del self.transitions[self.transitions_order[0]][0]
              del self.transitions_order[0]
      else:
          raise ValueError(
              "The granularity of the replay buffer can only be set in terms of transitions"
          )
  
imports: import operator
  import random
  from enum import Enum
  from typing import List, Tuple, Any, Union
  import numpy
  from rl_coach.core_types import Transition
  from rl_coach.memories.memory import MemoryGranularity
  from rl_coach.memories.non_episodic.experience_replay import ExperienceReplayParameters, ExperienceReplay
  from rl_coach.schedules import Schedule, ConstantSchedule
label_desc: Use image node_id 6 for calling the BalancedExperienceReplay obj's underlying member method code with example usage: obj._enforce_max_length() without return types