docstr: Store a new transition in the memory.
  :param transition: a transition to store
  :param lock: if true, will lock the readers writers lock. this can cause a deadlock if an inheriting class
               locks and then calls store with lock = True
  :return: None
docstr_tok: ["Store","a","new","transition","in","the","memory",".",":","param","transition",":","a","transition","to","store",":","param","lock",":","if","true",",","will","lock","the","readers","writers","lock",".","this","can","cause","a","deadlock","if","an","inheriting","class","locks","and","then","calls","store","with","lock","=","True",":","return",":","None"]
code: def store(self, transition: Transition, lock: bool = True) -> None:
      """
      Store a new transition in the memory.
      :param transition: a transition to store
      :param lock: if true, will lock the readers writers lock. this can cause a deadlock if an inheriting class
                   locks and then calls store with lock = True
      :return: None
      """
      # Calling super.store() so that in case a memory backend is used, the memory backend can store this transition.
      super().store(transition)
      if lock:
          self.reader_writer_lock.lock_writing_and_reading()
  
      self._num_transitions += 1
  
      if (
          self.state_key_with_the_class_index
          not in transition.state.keys()
      ):
          raise ValueError(
              "The class index was not present in the state of the transition under the given key ({})".format(
                  self.state_key_with_the_class_index
              )
          )
  
      class_idx = transition.state[self.state_key_with_the_class_index]
  
      if class_idx >= self.num_classes:
          raise ValueError(
              "The given class index is outside the defined number of classes for the replay buffer. "
              "The given class was: {} and the number of classes defined is: {}".format(
                  class_idx, self.num_classes
              )
          )
  
      self.transitions[class_idx].append(transition)
      self.transitions_order.append(class_idx)
      self._enforce_max_length()
  
      if lock:
          self.reader_writer_lock.release_writing_and_reading()
  
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 2 for calling the BalancedExperienceReplay obj's underlying member method code with example usage: obj.store(transition, lock) without return types