class_docstr: Hindsight Experience Replay (HER) https://arxiv.org/abs/1707.01495
  
  :param policy: (BasePolicy or str) The policy model to use (MlpPolicy, CnnPolicy, CnnLstmPolicy, ...)
  :param env: (Gym environment or str) The environment to learn from (if registered in Gym, can be str)
  :param model_class: (OffPolicyRLModel) The off policy RL model to apply Hindsight Experience Replay
      currently supported: DQN, DDPG, SAC
  :param n_sampled_goal: (int)
  :param goal_selection_strategy: (GoalSelectionStrategy or str)
code: def __init__(
      self,
      policy,
      env,
      model_class,
      n_sampled_goal=4,
      goal_selection_strategy="future",
      *args,
      **kwargs,
  ):
      assert not isinstance(
          env, VecEnvWrapper
      ), "HER does not support VecEnvWrapper"
  
      super().__init__(
          policy=policy,
          env=env,
          verbose=kwargs.get("verbose", 0),
          policy_base=None,
          requires_vec_env=False,
      )
  
      self.model_class = model_class
      self.replay_wrapper = None
      # Save dict observation space (used for checks at loading time)
      if env is not None:
          self.observation_space = env.observation_space
          self.action_space = env.action_space
  
      # Convert string to GoalSelectionStrategy object
      if isinstance(goal_selection_strategy, str):
          assert (
              goal_selection_strategy in KEY_TO_GOAL_STRATEGY.keys()
          ), "Unknown goal selection strategy"
          goal_selection_strategy = KEY_TO_GOAL_STRATEGY[
              goal_selection_strategy
          ]
  
      self.n_sampled_goal = n_sampled_goal
      self.goal_selection_strategy = goal_selection_strategy
  
      if self.env is not None:
          self._create_replay_wrapper(self.env)
  
      assert issubclass(
          model_class, OffPolicyRLModel
      ), "Error: HER only works with Off policy model (such as DDPG, SAC, TD3 and DQN)."
  
      self.model = self.model_class(policy, self.env, *args, **kwargs)
      # Patch to support saving/loading
      self.model._save_to_file = self._save_to_file
  
imports: import functools
  from stable_baselines.common import BaseRLModel
  from stable_baselines.common import OffPolicyRLModel
  from stable_baselines.common.base_class import _UnvecWrapper
  from stable_baselines.common.vec_env import VecEnvWrapper
  from .replay_buffer import HindsightExperienceReplayWrapper, KEY_TO_GOAL_STRATEGY
  from .utils import HERGoalEnvWrapper
label_desc: Use image node_id 1 to create a new HER object from inherited base classes: BaseRLModel with example: obj = HER(policy, env, model_class, n_sampled_goal, goal_selection_strategy)