docstr: Sample a batch of experiences.
  
  compared to ReplayBuffer.sample
  it also returns importance weights and idxes
  of sampled experiences.
  
  :param batch_size: (int) How many transitions to sample.
  :param beta: (float) To what degree to use importance weights (0 - no corrections, 1 - full correction)
  :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.
      - weights: (numpy float) Array of shape (batch_size,) and dtype np.float32 denoting importance weight of
          each sampled transition
      - idxes: (numpy int) Array of shape (batch_size,) and dtype np.int32 idexes in buffer of sampled experiences
docstr_tok: ["Sample","a","batch","of","experiences",".","compared","to","ReplayBuffer.sample","it","also","returns","importance","weights","and","idxes","of","sampled","experiences",".",":","param","batch_size",":","(","int",")","How","many","transitions","to","sample",".",":","param","beta",":","(","float",")","To","what","degree","to","use","importance","weights","(","0","-","no","corrections",",","1","-","full","correction",")",":","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",".","-","weights",":","(","numpy","float",")","Array","of","shape","(","batch_size",",",")","and","dtype","np.float32","denoting","importance","weight","of","each","sampled","transition","-","idxes",":","(","numpy","int",")","Array","of","shape","(","batch_size",",",")","and","dtype","np.int32","idexes","in","buffer","of","sampled","experiences"]
code: def sample(
      self,
      batch_size: int,
      beta: float = 0,
      env: Optional[VecNormalize] = None,
  ):
      """
      Sample a batch of experiences.
  
      compared to ReplayBuffer.sample
      it also returns importance weights and idxes
      of sampled experiences.
  
      :param batch_size: (int) How many transitions to sample.
      :param beta: (float) To what degree to use importance weights (0 - no corrections, 1 - full correction)
      :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.
          - weights: (numpy float) Array of shape (batch_size,) and dtype np.float32 denoting importance weight of
              each sampled transition
          - idxes: (numpy int) Array of shape (batch_size,) and dtype np.int32 idexes in buffer of sampled experiences
      """
      assert beta > 0
  
      idxes = self._sample_proportional(batch_size)
      weights = []
      p_min = self._it_min.min() / self._it_sum.sum()
      max_weight = (p_min * len(self._storage)) ** (-beta)
      p_sample = self._it_sum[idxes] / self._it_sum.sum()
      weights = (p_sample * len(self._storage)) ** (-beta) / max_weight
      encoded_sample = self._encode_sample(idxes, env=env)
      return tuple(list(encoded_sample) + [weights, idxes])
  
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 5 for calling the PrioritizedReplayBuffer obj's underlying member method code with example usage: obj.sample(batch_size, beta, env) and returns: tuple