code: def update(
      self,
      prediction: Union[Tensor, Dict],
      target: Union[Tensor, Dict],
      extras: Dict[str, Any] = None,
      batch_size: Optional[int] = 1,
  ) -> None:
      prediction = self.preprocess_predictions(prediction)
      target = self.preprocess_targets(target)
  
      if not isinstance(prediction, Tensor) or not isinstance(
          target, Tensor
      ):
          logger.error(
              "EpochMetric only works on Tensor, got {} and {}.".format(
                  type(prediction), type(target)
              )
              + " Please set pred_key or target_key by setting the proper metric name:"
              + " `stats.val: ['metric_name(pred=key1, target=key2)']`"
          )
          return
  
      if self.is_distributed:
          prediction = all_gather_list(prediction)
          target = all_gather_list(target)
      else:
          prediction = [prediction]
          target = [target]
  
      # Detach the variables: we don't need to backprop in metrics
      prediction = [x.detach() for x in prediction]
      target = [x.detach() for x in target]
      # By default we move things to CPU so as to not put extra burden on GPU memory
      # but we allow child-classes/instances to keep the data on GPU for efficiency.
      if self.force_cpu:
          prediction = [x.cpu() for x in prediction]
          target = [x.cpu() for x in target]
  
      self._predictions.extend(prediction)
      self._targets.extend(target)
  
imports: import abc
  import argparse
  from numbers import Number
  from typing import Any, Dict, List, Optional, Tuple, Union
  import numpy
  import torch
  from torch import Tensor
  from utils import logger
  from utils.tensor_utils import all_gather_list, reduce_tensor_sum, tensor_to_python_float
label_desc: Use image node_id 3 for calling the EpochMetric obj's underlying member method code with example usage: obj.update(prediction, target, extras, batch_size) without return types