class_docstr: A regular replay buffer which stores transition without any additional structure
docstr: Sample a batch of transitions form the replay buffer. If the requested size is larger than the number
  of samples available in the replay buffer then the batch will return empty.
  :param size: the size of the batch to sample
  :return: a batch (list) of selected transitions from the replay buffer
docstr_tok: ["Sample","a","batch","of","transitions","form","the","replay","buffer",".","If","the","requested","size","is","larger","than","the","number","of","samples","available","in","the","replay","buffer","then","the","batch","will","return","empty",".",":","param","size",":","the","size","of","the","batch","to","sample",":","return",":","a","batch","(","list",")","of","selected","transitions","from","the","replay","buffer"]
code: def sample(self, size: int) -> List[Transition]:
      """
      Sample a batch of transitions form the replay buffer. If the requested size is larger than the number
      of samples available in the replay buffer then the batch will return empty.
      :param size: the size of the batch to sample
      :return: a batch (list) of selected transitions from the replay buffer
      """
      self.reader_writer_lock.lock_writing()
  
      if self.allow_duplicates_in_batch_sampling:
          transitions_idx = np.random.randint(
              self.num_transitions(), size=size
          )
  
      else:
          if self.num_transitions() >= size:
              transitions_idx = np.random.choice(
                  self.num_transitions(), size=size, replace=False
              )
          else:
              raise ValueError(
                  "The replay buffer cannot be sampled since there are not enough transitions yet. "
                  "There are currently {} transitions".format(
                      self.num_transitions()
                  )
              )
  
      batch = [self.transitions[i] for i in transitions_idx]
  
      self.reader_writer_lock.release_writing()
      return batch
  
imports: from typing import List, Tuple, Union
  import pickle
  import random
  import math
  import numpy
  from rl_coach.core_types import Transition
  from rl_coach.logger import screen
  from rl_coach.memories.memory import Memory, MemoryGranularity, MemoryParameters
  from rl_coach.utils import ReaderWriterLock, ProgressBar
label_desc: Use image node_id 4 for calling the ExperienceReplay obj's underlying member method code with example usage: obj.sample(size) and returns: batch