code: def add_batch_stats(
      self, n_batches, preds, targets, scores, loss, m_input, **context
  ):
      super().add_batch_stats(
          n_batches, preds, targets, scores, None, m_input, **context
      )
      self.all_loss["all_loss"].append(float(loss[0]))
  
      custom_losses = loss[1].keys()
      for loss_name in custom_losses:
          vals = self.all_loss[loss_name]
          # samplewise losses are stored as multi-element tensors, so need to separate cases
          if "samplewise" in loss_name:
              vals.append(loss[1][loss_name].data.cpu().numpy())
          else:
              vals.append(float(loss[1][loss_name]))
  
imports: from collections import defaultdict
  from typing import Dict, List
  import numpy
  from pytext.common.constants import Stage
  from pytext.data.tensorizers import Tensorizer
  from pytext.metric_reporters.channel import ConsoleChannel
  from pytext.metric_reporters.compositional_metric_reporter import CompositionalMetricReporter
  from pytext.metric_reporters.seq2seq_compositional import CompositionalSeq2SeqFileChannel, Seq2SeqCompositionalMetricReporter
  from pytext.metrics.intent_slot_metrics import FramePredictionPair
  from pytext.metrics.mask_metrics import compute_masked_metrics, compute_nas_masked_metrics
  from .compositional_utils import extract_beam_subtrees, filter_invalid_beams
label_desc: Use image node_id 4 for calling the MaskedSeq2SeqCompositionalMetricReporter obj's underlying member method code with example usage: obj.add_batch_stats(n_batches, preds, targets, scores, loss, m_input) without return types