class_docstr: A replay buffer that stores episodes of transitions. The additional structure allows performing various
  calculations of total return and other values that depend on the sequential behavior of the transitions
  in the episode.
class_docstr_tok: ["A","replay","buffer","that","stores","episodes","of","transitions",".","The","additional","structure","allows","performing","various","calculations","of","total","return","and","other","values","that","depend","on","the","sequential","behavior","of","the","transitions","in","the","episode","."]
docstr: Shuffle all the complete episodes in the replay buffer, while deleting the last non-complete episode
  :return:
code: def shuffle_episodes(self):
      """
      Shuffle all the complete episodes in the replay buffer, while deleting the last non-complete episode
      :return:
      """
      self.reader_writer_lock.lock_writing()
  
      self.assert_not_frozen()
  
      # unlike the standard usage of the EpisodicExperienceReplay, where we always leave an empty episode after
      # the last full one, so that new transitions will have where to be added, in this case we delibrately remove
      # that empty last episode, as we are about to shuffle the memory, and we don't want it to be shuffled in
      self.remove_last_episode(lock=False)
  
      random.shuffle(self._buffer)
      self.transitions = [
          t for e in self._buffer for t in e.transitions
      ]
  
      # create a new Episode for the next transitions to be placed into
      self._buffer.append(Episode(n_step=self.n_step))
      self._length += 1
  
      self.reader_writer_lock.release_writing()
  
imports: import ast
  import pickle
  from copy import deepcopy
  import math
  import pandas
  from typing import List, Tuple, Union
  import numpy
  import random
  from rl_coach.core_types import Transition, Episode
  from rl_coach.filters.filter import InputFilter
  from rl_coach.logger import screen
  from rl_coach.memories.memory import Memory, MemoryGranularity, MemoryParameters
  from rl_coach.utils import ReaderWriterLock, ProgressBar
  from rl_coach.core_types import CsvDataset
label_desc: Use image node_id 9 for calling the EpisodicExperienceReplay obj's underlying member method code with example usage: obj.shuffle_episodes() without return types