code: def test_update_episode(her):
      episode = Episode()
      for i in range(10):
          episode.insert(
              Transition(
                  state={
                      "observation": np.array([i]),
                      "desired_goal": np.array([i + 1]),
                      "achieved_goal": np.array([i + 1]),
                  },
                  action=i,
                  game_over=i == 9,
                  reward=0 if i == 9 else -1,
              )
          )
  
      her.store_episode(episode)
      # print('her._num_transitions', her._num_transitions)
  
      # 10 original transitions, and 9 transitions * 4 hindsight episodes
      assert her.num_transitions() == 10 + (4 * 9)
  
      # make sure that the goal state was never sampled from the past
      for transition in her.transitions:
          assert (
              transition.state["desired_goal"]
              > transition.state["observation"]
          )
          assert (
              transition.next_state["desired_goal"]
              >= transition.next_state["observation"]
          )
  
          if transition.reward == 0:
              assert transition.game_over
          else:
              assert not transition.game_over
  
file_path: coach/rl_coach/tests/memories/test_hindsight_experience_replay.py
imports: import os
  import sys
  from rl_coach.memories.episodic.episodic_hindsight_experience_replay import EpisodicHindsightExperienceReplayParameters
  from rl_coach.spaces import GoalsSpace, ReachingGoal
  import pytest
  import numpy
  from rl_coach.core_types import Transition, Episode
  from rl_coach.memories.memory import MemoryGranularity
  from rl_coach.memories.episodic.episodic_hindsight_experience_replay import EpisodicHindsightExperienceReplay, HindsightGoalSelectionMethod
label_desc: Use image node_id 5 for calling a global function with example usage: test_update_episode(her) without return types