class_docstr: The Lightning Base module supporting SimCLR, MoCo and BYOL SSL tasks.
  
  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.
      knn_memory (OmegaConf): An optional hydra / omeaga conf, if set, initializes KNN
          Memory module to use. Example config can be found at,
          `pytorchvideo_trainer/conf/module/knn_memory`.
      momentum_anneal_cosine (bool): For MoCo and BYOL tasks, if set to true, cosine
          anneals the momentum term used from updating the backbone-history model.
      num_sync_devices (int): Number of gpus to sync bathcnorm over. Only works if
          pytorch lightning trainer's sync_batchnorm parameter is to false.
class_docstr_tok: ["The","Lightning","Base","module","supporting","SimCLR",",","MoCo","and","BYOL","SSL","tasks",".","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",".","knn_memory","(","OmegaConf",")",":","An","optional","hydra","\/","omeaga","conf",",","if","set",",","initializes","KNN","Memory","module","to","use",".","Example","config","can","be","found","at",",","`","pytorchvideo_trainer\/conf\/module\/knn_memory","`",".","momentum_anneal_cosine","(","bool",")",":","For","MoCo","and","BYOL","tasks",",","if","set","to","true",",","cosine","anneals","the","momentum","term","used","from","updating","the","backbone-history","model",".","num_sync_devices","(","int",")",":","Number","of","gpus","to","sync","bathcnorm","over",".","Only","works","if","pytorch","lightning","trainer","'s","sync_batchnorm","parameter","is","to","false","."]
code: def __init__(
      self,
      model: Any,  # pyre-ignore[2]
      loss: Any,  # pyre-ignore[2]
      optim: Any,  # pyre-ignore[2]
      metrics: List[Any],  # pyre-ignore[2]
      lr_scheduler: Optional[Any] = None,  # pyre-ignore[2]
      modality_key: BatchKey = "video",
      ensemble_method: Optional[EnsembleMethod] = None,
      knn_memory: Optional[Any] = None,  # pyre-ignore[2]
      momentum_anneal_cosine: bool = False,  # TODO: Refactor out mmt from base class.
      num_sync_devices: int = 1,
  ) -> None:
      super().__init__(
          model=model,
          loss=loss,
          optim=optim,
          metrics=metrics,
          lr_scheduler=lr_scheduler,
          modality_key=modality_key,
          ensemble_method=ensemble_method,
          num_sync_devices=num_sync_devices,
      )
  
      self.knn_memory: nn.Module = instantiate(knn_memory)
      self.automatic_optimization = False
      self.momentum_anneal_cosine = momentum_anneal_cosine
      if self.momentum_anneal_cosine:
          self.initial_mmt: float = self.model.mmt  # pyre-ignore[8]
  
      if ensemble_method is not None:
          assert (
              self.knn_memory is not None
          ), "Test-Ensembling is only supported with KNN module"
  
imports: import math
  from typing import Any, Callable, Dict, List, Optional
  import numpy
  import pytorchvideo_trainer.module.distributed_utils
  import torch
  import torch.nn
  import torch.nn.functional
  from hydra.utils import instantiate
  from pytorch_lightning.trainer import Trainer
  from pytorchvideo_trainer.module.video_classification import Batch, BatchKey, EnsembleMethod, VideoClassificationModule
label_desc: Use image node_id 1 to create a new SSLBaseModule object from inherited base classes: VideoClassificationModule with example: obj = SSLBaseModule(model, loss, optim, metrics, lr_scheduler, modality_key, ensemble_method, knn_memory, momentum_anneal_cosine, num_sync_devices)