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.
docstr: Method to be called everytime you need to check whether to
  early stop or not
  Arguments:
      update {number}: Current update number
      iteration {number}: Current iteration number
  Returns:
      bool -- Tells whether early stopping occurred or not
code: def __call__(self, update, iteration, meter):
      """
      Method to be called everytime you need to check whether to
      early stop or not
      Arguments:
          update {number}: Current update number
          iteration {number}: Current iteration number
      Returns:
          bool -- Tells whether early stopping occurred or not
      """
      # There are operations involving synchronization downstream
      # For XLA those calls must be executed from all cores
      # Therefore we do return here in case of XLA
      if not is_main() and not is_xla():
          return False
  
      value = meter.meters.get(self.early_stop_criteria, None)
      if value is None:
          raise ValueError(
              "Criteria used for early stopping ({}) is not "
              "present in meter.".format(self.early_stop_criteria)
          )
  
      value = value.global_avg
  
      if isinstance(value, torch.Tensor):
          value = value.item()
  
      if (self.minimize and value < self.best_monitored_value) or (
          not self.minimize and value > self.best_monitored_value
      ):
          self.best_monitored_value = value
          self.best_monitored_iteration = iteration
          self.best_monitored_update = update
          self.checkpoint.save(update, iteration, update_best=True)
  
      elif self.best_monitored_update + self.patience < update:
          self.activated = True
          if self.should_stop is True:
              self.checkpoint.restore()
              self.checkpoint.finalize()
              return True
          else:
              return False
      else:
          self.checkpoint.save(update, iteration, update_best=False)
  
      return False
  
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 2 for calling the EarlyStopping obj's underlying member method code with example usage: obj.__call__(update, iteration, meter) and returns: False, False, True, False