code: def add_batch_stats(
      self, n_batches, preds, targets, scores, loss, m_input, **context
  ):
      now = time.time()
  
      total_masked_tokens = targets[1].sum().item()
      self.aggregate_loss += loss.item() * total_masked_tokens
      self.total_masked_tokens += total_masked_tokens
  
      # realtime stats
      total_tokens = float(targets[2].sum())
      self.realtime_meters["tps"].update(total_tokens)
      self.last_batch_tps = total_tokens / (now - self.time + 1e-6)
      self.last_batch_loss = loss.item()
      self.total_batches = n_batches
      self.time = now
  
imports: import json
  import math
  import operator
  import time
  import torch
  import torch.nn.functional
  from pytext.common.constants import Stage
  from pytext.config.module_config import PerplexityType
  from pytext.data import CommonMetadata
  from pytext.metrics.language_model_metrics import compute_language_model_metric, LanguageModelMetric
  from pytext.utils import cuda
  from .channel import ConsoleChannel, FileChannel
  from .metric_reporter import MetricReporter
label_desc: Use image node_id 2 for calling the MaskedLMMetricReporter obj's underlying member method code with example usage: obj.add_batch_stats(n_batches, preds, targets, scores, loss, m_input) without return types