code: def _update_monitor(self, losses, metrics):
      monitor = {}
  
      if self._model_state == enums.ModelState.TRAIN:
          metrics_meter = self.train_meter
          _bs = self.train_loader_bs
      elif self._model_state == enums.ModelState.VALID:
          metrics_meter = self.valid_meter
          _bs = self.valid_loader_bs
      else:
          raise ValueError("Invalid model state")
  
      for m_m in metrics_meter:
          metrics_meter[m_m].update(
              metrics[m_m].cpu().detach().numpy(), _bs
          )
          monitor[m_m] = metrics_meter[m_m].avg
  
      if self._model_state == enums.ModelState.TRAIN:
          self.train_meter = metrics_meter
      elif self._model_state == enums.ModelState.VALID:
          self.valid_meter = metrics_meter
      else:
          raise ValueError("Invalid model state")
      self.update_metrics(losses=losses, monitor=monitor)
      return monitor
  
imports: import multiprocessing
  import time
  import warnings
  from dataclasses import dataclass
  from typing import Optional
  import torch
  from accelerate import Accelerator
  from torch.utils.data import DataLoader
  from tez import enums
  from tez.callbacks import CallbackRunner, Progress
  from tez.logger import logger
  from tez.utils import AverageMeter
  from .config import TezConfig
label_desc: Use image node_id 20 for calling the Tez obj's underlying member method code with example usage: obj._update_monitor(losses, metrics) and returns: monitor