code: def create_classification_model_from_ssl_checkpoint(
      ssl_checkpoint_path: str,
      checkpoint_type: str,
      mlp: Optional[nn.Module] = None,
      detach_backbone: bool = False,
  ) -> nn.Module:
      """
      A utlity function for extracting the bacbone from the PyTorch Lightning's
      SSL checkpoints. Used for supervided finetuning the SSL pre-trained models
      in video classification task.
  
      Extracts bacbone from the checkpoints of the SimCLR, BYOL and MoCoV2 SSL
      tasks and attaches the given MLP to the backbone.
  
      Args:
          ssl_checkpoint_path (str): Path to the lightning checkpoint for the
              said SSL task.
          checkpoint_type (str): Type of the SSL task the checkpoint belongs to.
              Should be one of ["simclr, "byol", "mocov_v2"]
          mlp (nn.Module): If specified, the MLP module to attach to the bacbone
              for the supervised finetuning phase.
          detach_bacbone: If true, detaches bacbone and no gradient are tracked and
              updated for the bacbone. Only updates the MLP weights during finetuning.
  
      Returns:
          model (SSLFineTuningModel): Returns an instance of `SSLFineTuningModel`,
              consisting of bacbone and mlp.
      """
  
      if checkpoint_type == "simclr":
          from pytorchvideo_trainer.module.simclr import (
              SimCLRModule as M,
          )
  
          lightning_module = M.load_from_checkpoint(ssl_checkpoint_path)
          backbone = lightning_module.model.backbone[0]
      elif checkpoint_type == "byol":
          from pytorchvideo_trainer.module.byol import BYOLModule as M
  
          lightning_module = M.load_from_checkpoint(ssl_checkpoint_path)
          backbone = lightning_module.model.backbone[0]
      elif checkpoint_type == "moco_v2":
          from pytorchvideo_trainer.module.moco_v2 import (
              MOCOV2Module as M,
          )
  
          lightning_module = M.load_from_checkpoint(ssl_checkpoint_path)
          backbone = lightning_module.model.backbone[0]
      else:
          raise ValueError("Incorrect SSL checkpoint type.")
  
      # pyre-ignore[6]
      return SSLFineTuningModel(backbone, mlp, detach_backbone)
  
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 2 for calling a global function with example usage: create_classification_model_from_ssl_checkpoint(ssl_checkpoint_path, checkpoint_type, mlp, detach_backbone) and returns: SSLFineTuningModel