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: Close the last episode in the replay buffer and open a new one
  :return: None
code: def close_last_episode(self, lock=True) -> None:
      """
      Close the last episode in the replay buffer and open a new one
      :return: None
      """
      if lock:
          self.reader_writer_lock.lock_writing_and_reading()
  
      last_episode = self._buffer[-1]
  
      self._num_transitions_in_complete_episodes += (
          last_episode.length()
      )
      self._length += 1
  
      # create a new Episode for the next transitions to be placed into
      self._buffer.append(Episode(n_step=self.n_step))
  
      # if update episode adds to the buffer, a new Episode needs to be ready first
      # it would be better if this were less state full
      self._update_episode(last_episode)
  
      self._enforce_max_length()
  
      if lock:
          self.reader_writer_lock.release_writing_and_reading()
  
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 17 for calling the EpisodicExperienceReplay obj's underlying member method code with example usage: obj.close_last_episode(lock) without return types