class_docstr: callback to be used with LightningTrainer and torchmetric
  Warning: 'optimizer.enable_state_sharding=True' is not supported
code: def _log_metrics_and_extra(
      self,
      extra: Optional[Dict],
      num_updates: int,
      max_updates: int,
      log_type: str = "train",
  ):
      logger.info(f"{num_updates}/{max_updates}")
      if extra is not None:
          logger.info(
              ", ".join(
                  [f"{key}: {value}" for key, value in extra.items()]
              )
          )
      scalar_dict = (
          self.lightning_trainer.torchmetrics.get_scalar_dict()
      )
      scalar_dict_with_type = {
          f"{log_type}_{k}": v for k, v in scalar_dict.items()
      }
      if self.lightning_trainer.tb_writer is not None:
          self.lightning_trainer.tb_writer.add_scalars(
              scalar_dict_with_type, num_updates
          )
      logger.info(f"{log_type} metrics:")
      logger.info(
          ", ".join(
              [f"{key}: {value}" for key, value in scalar_dict.items()]
          )
      )
  
imports: import logging
  from typing import Any, Dict, List, Optional
  import torch
  from mmf.common.registry import registry
  from mmf.common.sample import SampleList
  from mmf.utils.timer import Timer
  from pytorch_lightning import LightningModule, Trainer
  from pytorch_lightning.callbacks.base import Callback
label_desc: Use image node_id 7 for calling the LightningTorchMetricsCallback obj's underlying member method code with example usage: obj._log_metrics_and_extra(extra, num_updates, max_updates, log_type) without return types