class_docstr: Class to help manage, save, clean up, and average checkpoints.
docstr: Args:
    num_avg_checkpoints: Number of checkpoints to average over.
    auto_clear_checkpoints: If True, we automatically delete
        checkpoints older than args.num_avg_checkpoints.
    log_verbose:
docstr_tok: ["Args",":","num_avg_checkpoints",":","Number","of","checkpoints","to","average","over",".","auto_clear_checkpoints",":","If","True",",","we","automatically","delete","checkpoints","older","than","args.num_avg_checkpoints",".","log_verbose",":"]
code: def __init__(
      self,
      num_avg_checkpoints: int,
      auto_clear_checkpoints: bool,
      log_verbose: bool,
      checkpoint_files: List[str],
  ):
      """
      Args:
        num_avg_checkpoints: Number of checkpoints to average over.
        auto_clear_checkpoints: If True, we automatically delete
            checkpoints older than args.num_avg_checkpoints.
        log_verbose:
      """
      assert (
          num_avg_checkpoints > 0
      ), "Must average over at least one checkpoint."
      self._num_avg_checkpoints: int = num_avg_checkpoints
      self._auto_clear_checkpoints: bool = auto_clear_checkpoints
      self._log_verbose: bool = log_verbose
      self._averaged_params: OrderedDict = OrderedDict()
      self._checkpoint_files: Deque[str] = deque(
          maxlen=self._num_avg_checkpoints
      )
      # Updates the checkpoint files deque and discards any checkpoint files
      # older than the limit.
      for file in checkpoint_files:
          self._checkpoint_files.append(file)
      # Defers actually reading the checkpoint files until later due to
      # T39501955.
      self._initialized = False
  
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 1 to create a new CheckpointManager object  with example: obj = CheckpointManager(num_avg_checkpoints, auto_clear_checkpoints, log_verbose, checkpoint_files)