docstr: Sample a batch of experiences.
  
  :param batch_size: (int) How many transitions to sample.
  :param env: (Optional[VecNormalize]) associated gym VecEnv
      to normalize the observations/rewards when sampling
  :return:
      - obs_batch: (np.ndarray) batch of observations
      - act_batch: (numpy float) batch of actions executed given obs_batch
      - rew_batch: (numpy float) rewards received as results of executing act_batch
      - next_obs_batch: (np.ndarray) next set of observations seen after executing act_batch
      - done_mask: (numpy bool) done_mask[i] = 1 if executing act_batch[i] resulted in the end of an episode
          and 0 otherwise.
docstr_tok: ["Sample","a","batch","of","experiences",".",":","param","batch_size",":","(","int",")","How","many","transitions","to","sample",".",":","param","env",":","(","Optional","[","VecNormalize","]",")","associated","gym","VecEnv","to","normalize","the","observations\/rewards","when","sampling",":","return",":","-","obs_batch",":","(","np.ndarray",")","batch","of","observations","-","act_batch",":","(","numpy","float",")","batch","of","actions","executed","given","obs_batch","-","rew_batch",":","(","numpy","float",")","rewards","received","as","results","of","executing","act_batch","-","next_obs_batch",":","(","np.ndarray",")","next","set","of","observations","seen","after","executing","act_batch","-","done_mask",":","(","numpy","bool",")","done_mask","[","i","]","=","1","if","executing","act_batch","[","i","]","resulted","in","the","end","of","an","episode","and","0","otherwise","."]
code: def sample(
      self,
      batch_size: int,
      env: Optional[VecNormalize] = None,
      **_kwargs,
  ):
      """
      Sample a batch of experiences.
  
      :param batch_size: (int) How many transitions to sample.
      :param env: (Optional[VecNormalize]) associated gym VecEnv
          to normalize the observations/rewards when sampling
      :return:
          - obs_batch: (np.ndarray) batch of observations
          - act_batch: (numpy float) batch of actions executed given obs_batch
          - rew_batch: (numpy float) rewards received as results of executing act_batch
          - next_obs_batch: (np.ndarray) next set of observations seen after executing act_batch
          - done_mask: (numpy bool) done_mask[i] = 1 if executing act_batch[i] resulted in the end of an episode
              and 0 otherwise.
      """
      idxes = [
          random.randint(0, len(self._storage) - 1)
          for _ in range(batch_size)
      ]
      return self._encode_sample(idxes, env=env)
  
imports: import random
  from typing import Optional, List, Union
  import numpy
  from stable_baselines.common.segment_tree import SumSegmentTree, MinSegmentTree
  from stable_baselines.common.vec_env import VecNormalize
label_desc: Use image node_id 12 for calling the ReplayBuffer obj's underlying member method code with example usage: obj.sample(batch_size, env) and returns: self