class_docstr: Replay buffer for HER (Hindsight Experience Replay).
  
  It constructs hindsight examples using future strategy.
  
  Args:
      replay_k (int): Number of HER transitions to add for each regular
          Transition. Setting this to 0 means that no HER replays will
          be added.
      reward_fn (callable): Function to re-compute the reward with
          substituted goals.
      capacity_in_transitions (int): total size of transitions in the buffer.
      env_spec (EnvSpec): Environment specification.
class_docstr_tok: ["Replay","buffer","for","HER","(","Hindsight","Experience","Replay",")",".","It","constructs","hindsight","examples","using","future","strategy",".","Args",":","replay_k","(","int",")",":","Number","of","HER","transitions","to","add","for","each","regular","Transition",".","Setting","this","to","0","means","that","no","HER","replays","will","be","added",".","reward_fn","(","callable",")",":","Function","to","re-compute","the","reward","with","substituted","goals",".","capacity_in_transitions","(","int",")",":","total","size","of","transitions","in","the","buffer",".","env_spec","(","EnvSpec",")",":","Environment","specification","."]
docstr: Samples HER goals from the given path.
  
  Goals are randomly sampled starting from the index after
  transition_idx in the given path.
  
  Args:
      path (dict[str, np.ndarray]): A dict containing the transition
          keys, where each key contains an ndarray of shape
          :math:`(T, S^*)`.
      transition_idx (int): index of the current transition. Only
          transitions after the current transitions will be randomly
          sampled for HER goals.
  
  Returns:
      np.ndarray: A numpy array of HER goals with shape
          (replay_k, goal_dim).
docstr_tok: ["Samples","HER","goals","from","the","given","path",".","Goals","are","randomly","sampled","starting","from","the","index","after","transition_idx","in","the","given","path",".","Args",":","path","(","dict","[","str",",","np.ndarray","]",")",":","A","dict","containing","the","transition","keys",",","where","each","key","contains","an","ndarray","of","shape",":","math",":","`","(","T",",","S^","*",")","`",".","transition_idx","(","int",")",":","index","of","the","current","transition",".","Only","transitions","after","the","current","transitions","will","be","randomly","sampled","for","HER","goals",".","Returns",":","np.ndarray",":","A","numpy","array","of","HER","goals","with","shape","(","replay_k",",","goal_dim",")","."]
code: def _sample_her_goals(self, path, transition_idx):
      """Samples HER goals from the given path.
  
      Goals are randomly sampled starting from the index after
      transition_idx in the given path.
  
      Args:
          path (dict[str, np.ndarray]): A dict containing the transition
              keys, where each key contains an ndarray of shape
              :math:`(T, S^*)`.
          transition_idx (int): index of the current transition. Only
              transitions after the current transitions will be randomly
              sampled for HER goals.
  
      Returns:
          np.ndarray: A numpy array of HER goals with shape
              (replay_k, goal_dim).
  
      """
      goal_indexes = np.random.randint(
          transition_idx + 1,
          len(path["observations"]),
          size=self._replay_k,
      )
      return [
          goal["achieved_goal"]
          for goal in np.asarray(path["observations"])[goal_indexes]
      ]
  
file_path: garage/src/garage/replay_buffer/her_replay_buffer.py
imports: import copy
  import numpy
  from garage.replay_buffer.path_buffer import PathBuffer
label_desc: Use image node_id 2 for calling the HERReplayBuffer obj's underlying member method code with example usage: obj._sample_her_goals(path, transition_idx) and returns: unknown