class_docstr: Class to help manage, save, clean up, and average checkpoints.
code: def _update_state(
      self, new_params_filename: str, new_averaged_params: OrderedDict
  ) -> Optional[str]:
      # Consider making a copy of each tensor here if we run into issues in
      # the future with callers later modifying the params passed in.
      self._averaged_params = new_averaged_params
  
      checkpoint_to_remove = None
      if (
          self._auto_clear_checkpoints
          and len(self._checkpoint_files)
          == self._checkpoint_files.maxlen
      ):
          # We delay actually removing this checkpoint until after the newest
          # checkpoint has been successfully written.
          checkpoint_to_remove = self._checkpoint_files.popleft()
  
      # Make sure to include the checkpoint itself in its list of checkpoint
      # files - this is to ensure we can still restore everything correctly
      # even if the file gets copied to another name (ex: checkpoint_last.py).
      self._checkpoint_files.append(new_params_filename)
      return checkpoint_to_remove
  
imports: import os
  from collections import deque, OrderedDict
  from typing import Any, Deque, Dict, List, Optional, Tuple
  import torch
  from fairseq import checkpoint_utils, utils
  from pytorch_translate import constants
  from pytorch_translate.file_io import PathManager
label_desc: Use image node_id 6 for calling the CheckpointManager obj's underlying member method code with example usage: obj._update_state(new_params_filename, new_averaged_params) and returns: checkpoint_to_remove