class_docstr: The Lightning module supporting the video classification task.
  
  Args:
      model (OmegaConf): An omega conf object intializing the neural-network modle.
          Example configs can be found in `pytorchvideo_trainer/conf/module/model`
      loss(OmegaConf): An omega conf object intializing the loss function.
          Example configs can be found in `pytorchvideo_trainer/conf/module/loss`
      optim (OmegaConf): An omega conf object for constructing the optimizer object.
          The associated config schema can be found at
          `pytorchvideo_trainer.module.optimizer.OptimizerConf`.
          Example configs can be found in `pytorchvideo_trainer/conf/module/optim`
      metrics (OmegaConf): The metrics to track, which will be used for both train,
          validation and test. Example configs can be found in
          `pytorchvideo_trainer/conf/module/metricx`
      lr_scheduler (OmegaConf): An omega conf object associated with learning rate
          scheduler used during trainer.
          The associated config schema can be found at
          `pytorchvideo_trainer.module.lr_policy.LRSchedulerConf`.
          Example configs can be found in `pytorchvideo_trainer/conf/module/lr_scheduler`
      modality_key (str): The modality key used in data processing, default: "video".
      ensemble_method (str): The data ensembling method to control how we accumulate
          the testing results at video level, which is optional. Users may choose from
          ["sum", "max", None], If it is set to None, no data ensembling will be applied.
      num_classes (int): The number of classes in the dataset.
      num_sync_devices (int): Number of gpus to sync bathcnorm over. Only works if
          pytorch lightning trainer's sync_batchnorm parameter is to false.
      batch_transform (OmegaConf): An optional omega conf object, for constructing the
          data transform method that act upon the entire mini batch. Examples include,
          MixVideo transform, etc.
      clip_gradient_norm (float): Performs gradient clipping if set to a positive value.
          Since, we use Pytorch-lightning's manual optimization approach gradient clipping
          has to be be set in the lightning module instead of the Trainer object.
class_docstr_tok: ["The","Lightning","module","supporting","the","video","classification","task",".","Args",":","model","(","OmegaConf",")",":","An","omega","conf","object","intializing","the","neural-network","modle",".","Example","configs","can","be","found","in","`","pytorchvideo_trainer\/conf\/module\/model","`","loss","(","OmegaConf",")",":","An","omega","conf","object","intializing","the","loss","function",".","Example","configs","can","be","found","in","`","pytorchvideo_trainer\/conf\/module\/loss","`","optim","(","OmegaConf",")",":","An","omega","conf","object","for","constructing","the","optimizer","object",".","The","associated","config","schema","can","be","found","at","`","pytorchvideo_trainer.module.optimizer.OptimizerConf","`",".","Example","configs","can","be","found","in","`","pytorchvideo_trainer\/conf\/module\/optim","`","metrics","(","OmegaConf",")",":","The","metrics","to","track",",","which","will","be","used","for","both","train",",","validation","and","test",".","Example","configs","can","be","found","in","`","pytorchvideo_trainer\/conf\/module\/metricx","`","lr_scheduler","(","OmegaConf",")",":","An","omega","conf","object","associated","with","learning","rate","scheduler","used","during","trainer",".","The","associated","config","schema","can","be","found","at","`","pytorchvideo_trainer.module.lr_policy.LRSchedulerConf","`",".","Example","configs","can","be","found","in","`","pytorchvideo_trainer\/conf\/module\/lr_scheduler","`","modality_key","(","str",")",":","The","modality","key","used","in","data","processing",",","default",":","``","video","''",".","ensemble_method","(","str",")",":","The","data","ensembling","method","to","control","how","we","accumulate","the","testing","results","at","video","level",",","which","is","optional",".","Users","may","choose","from","[","``","sum","''",",","``","max","''",",","None","]",",","If","it","is","set","to","None",",","no","data","ensembling","will","be","applied",".","num_classes","(","int",")",":","The","number","of","classes","in","the","dataset",".","num_sync_devices","(","int",")",":","Number","of","gpus","to","sync","bathcnorm","over",".","Only","works","if","pytorch","lightning","trainer","'s","sync_batchnorm","parameter","is","to","false",".","batch_transform","(","OmegaConf",")",":","An","optional","omega","conf","object",",","for","constructing","the","data","transform","method","that","act","upon","the","entire","mini","batch",".","Examples","include",",","MixVideo","transform",",","etc",".","clip_gradient_norm","(","float",")",":","Performs","gradient","clipping","if","set","to","a","positive","value",".","Since",",","we","use","Pytorch-lightning","'s","manual","optimization","approach","gradient","clipping","has","to","be","be","set","in","the","lightning","module","instead","of","the","Trainer","object","."]
code: def _step(
      self, batch: Batch, batch_idx: int, phase_type: str
  ) -> Dict[str, Any]:
      assert (
          isinstance(batch, dict)
          and self.modality_key in batch
          and "label" in batch
      ), (
          f"Returned batch [{batch}] is not a map with '{self.modality_key}' and"
          + "'label' keys"
      )
  
      y_hat = self(batch[self.modality_key])
      if phase_type == "train":
          loss = self.loss(y_hat, batch["label"])
          self.log(
              f"Losses/{phase_type}_loss",
              loss,
              on_step=True,
              on_epoch=True,
              prog_bar=True,
          )
      else:
          loss = None
  
      ## TODO: Move MixUP transform metrics to sperate method.
      if (
          phase_type == "train"
          and self.batch_transform is not None
          and isinstance(self.batch_transform, MixVideoBatchWrapper)
      ):
          _top_max_k_vals, top_max_k_inds = torch.topk(
              batch["label"], 2, dim=1, largest=True, sorted=True
          )
          idx_top1 = (
              torch.arange(batch["label"].shape[0]),
              top_max_k_inds[:, 0],
          )
          idx_top2 = (
              torch.arange(batch["label"].shape[0]),
              top_max_k_inds[:, 1],
          )
          y_hat = y_hat.detach()
          y_hat[idx_top1] += y_hat[idx_top2]
          y_hat[idx_top2] = 0.0
          batch["label"] = top_max_k_inds[:, 0]
  
      pred = torch.nn.functional.softmax(y_hat, dim=-1)
      metrics_result = self._compute_metrics(
          pred, batch["label"], phase_type
      )
      self.log_dict(metrics_result, on_epoch=True)
  
      return loss
  
imports: from dataclasses import dataclass
  from typing import Any, Dict, Iterable, List, Literal, Mapping, Optional, Tuple, TypedDict, Union
  import pytorch_lightning
  import torch
  from hydra.core.config_store import ConfigStore
  from hydra.utils import instantiate
  from iopath.common.file_io import g_pathmgr
  from omegaconf import MISSING, OmegaConf
  from pytorch_lightning.utilities import rank_zero_info
  from pytorchvideo_trainer.datamodule.transforms import MixVideoBatchWrapper
  from pytorchvideo_trainer.module.lr_policy import get_epoch_lr, LRSchedulerConf, set_lr
  from pytorchvideo_trainer.module.optimizer import construct_optimizer
  from torch import nn
  from torch.optim.lr_scheduler import _LRScheduler
  from torchrecipes.core.conf import ModuleConf
  from torchrecipes.utils.config_utils import get_class_name_str
label_desc: Use image node_id 18 for calling the VideoClassificationModule obj's underlying member method code with example usage: obj._step(batch, batch_idx, phase_type) and returns: loss