class_docstr: Provides early stopping functionality. Keeps track of an early stop criteria,
  and if it doesn't improve over time restores last best performing
  parameters.
code: def __init__(
      self,
      model,
      checkpoint_instance,
      early_stop_criteria="total_loss",
      patience=1000,
      minimize=False,
      should_stop=True,
  ):
      self.minimize = minimize
      self.patience = patience
      self.model = model
      self.checkpoint = checkpoint_instance
      self.early_stop_criteria = early_stop_criteria
  
      if "val" not in self.early_stop_criteria:
          self.early_stop_criteria = f"val/{self.early_stop_criteria}"
  
      self.best_monitored_value = -np.inf if not minimize else np.inf
      self.best_monitored_iteration = 0
      self.best_monitored_update = 0
      self.should_stop = should_stop
      self.activated = False
      self.metric = self.early_stop_criteria
  
file_path: mmf/mmf/utils/early_stopping.py
imports: import numpy
  import torch
  from mmf.utils.distributed import is_main, is_xla
label_desc: Use image node_id 1 to create a new EarlyStopping object  with example: obj = EarlyStopping(model, checkpoint_instance, early_stop_criteria, patience, minimize, should_stop)