class_docstr: Members:
      eval_only: If True, only run evaluation using the test dataloader.
      max_epochs: Train for this many epochs. Note that if the model was
          loaded from a checkpoint, we will restart training at the appropriate
          epoch and run for (max_epochs - checkpoint_epoch) epochs.
      store_checkpoints: If True, store model and optimizer state checkpoints.
      store_checkpoints_purge: If >= 0, remove any checkpoints older or equal
          to this many epochs.
      test_interval: Evaluate on a test dataloader each `test_interval` epochs.
      test_when_finished: If True, evaluate on a test dataloader when training
          completes.
      validation_interval: Validate each `validation_interval` epochs.
      clip_grad: Optionally clip the gradient norms.
          If set to a value <=0.0, no clipping
      metric_print_interval: The batch interval at which the stats should be
          logged.
      visualize_interval: The batch interval at which the visualizations
          should be plotted
      visdom_env: The name of the Visdom environment to use for plotting.
      visdom_port: The Visdom port.
      visdom_server: Address of the Visdom server.
docstr: Save a model and its corresponding Stats object to a file, if
  `self.store_checkpoints` is True. In addition, if
  `self.store_checkpoints_purge` is True, remove any checkpoints older
  than `self.store_checkpoints_purge` epochs old.
docstr_tok: ["Save","a","model","and","its","corresponding","Stats","object","to","a","file",",","if","`","self.store_checkpoints","`","is","True",".","In","addition",",","if","`","self.store_checkpoints_purge","`","is","True",",","remove","any","checkpoints","older","than","`","self.store_checkpoints_purge","`","epochs","old","."]
code: def _checkpoint(
      self,
      accelerator: Optional[Accelerator],
      epoch: int,
      exp_dir: str,
      model: ImplicitronModelBase,
      optimizer: torch.optim.Optimizer,
      stats: Stats,
  ):
      """
      Save a model and its corresponding Stats object to a file, if
      `self.store_checkpoints` is True. In addition, if
      `self.store_checkpoints_purge` is True, remove any checkpoints older
      than `self.store_checkpoints_purge` epochs old.
      """
      if self.store_checkpoints and (
          accelerator is None or accelerator.is_local_main_process
      ):
          if self.store_checkpoints_purge > 0:
              for prev_epoch in range(
                  epoch - self.store_checkpoints_purge
              ):
                  model_io.purge_epoch(exp_dir, prev_epoch)
          outfile = model_io.get_checkpoint(exp_dir, epoch)
          unwrapped_model = (
              model
              if accelerator is None
              else accelerator.unwrap_model(model)
          )
          model_io.safe_save_model(
              unwrapped_model, stats, outfile, optimizer=optimizer
          )
  
imports: import logging
  import os
  import time
  from typing import Any, List, Optional
  import torch
  from accelerate import Accelerator
  from pytorch3d.implicitron.evaluation.evaluator import EvaluatorBase
  from pytorch3d.implicitron.models.base_model import ImplicitronModelBase
  from pytorch3d.implicitron.models.generic_model import EvaluationMode
  from pytorch3d.implicitron.tools import model_io, vis_utils
  from pytorch3d.implicitron.tools.config import registry, ReplaceableBase, run_auto_creation
  from pytorch3d.implicitron.tools.stats import Stats
  from torch.utils.data import DataLoader, Dataset
  from .utils import seed_all_random_engines
label_desc: Use image node_id 5 for calling the ImplicitronTrainingLoop obj's underlying member method code with example usage: obj._checkpoint(accelerator, epoch, exp_dir, model, optimizer, stats) without return types