class_docstr: A task prepares and holds all the components of a training like optimizer, datasets,
  dataloaders, losses, meters etc. Task also contains the variable like training iteration,
  epoch number etc. that are updated during the training.
  
  We prepare every single component according to the parameter settings user wants
  and specified in the yaml config file.
  
  Task also supports 2 additional things:
  1) converts the model BatchNorm layers to the synchronized batchnorm
  2) sets mixed precision (apex and pytorch both supported)
class_docstr_tok: ["A","task","prepares","and","holds","all","the","components","of","a","training","like","optimizer",",","datasets",",","dataloaders",",","losses",",","meters","etc",".","Task","also","contains","the","variable","like","training","iteration",",","epoch","number","etc",".","that","are","updated","during","the","training",".","We","prepare","every","single","component","according","to","the","parameter","settings","user","wants","and","specified","in","the","yaml","config","file",".","Task","also","supports","2","additional","things",":","1",")","converts","the","model","BatchNorm","layers","to","the","synchronized","batchnorm","2",")","sets","mixed","precision","(","apex","and","pytorch","both","supported",")"]
docstr: If using a weights file to initialize the model, we load the weights
  and initialize the model. Since the weights file specified
  by user might not be VISSL trained weights, we expose several config
  options like APPEND_PREFIX, etc to allow successful loading of the weights.
  See MODEL.WEIGHTS_INIT description in vissl/config/defaults.yaml for details.
docstr_tok: ["If","using","a","weights","file","to","initialize","the","model",",","we","load","the","weights","and","initialize","the","model",".","Since","the","weights","file","specified","by","user","might","not","be","VISSL","trained","weights",",","we","expose","several","config","options","like","APPEND_PREFIX",",","etc","to","allow","successful","loading","of","the","weights",".","See","MODEL.WEIGHTS_INIT","description","in","vissl\/config\/defaults.yaml","for","details","."]
code: def _restore_model_weights(self, model, strict: bool = False):
      """
      If using a weights file to initialize the model, we load the weights
      and initialize the model. Since the weights file specified
      by user might not be VISSL trained weights, we expose several config
      options like APPEND_PREFIX, etc to allow successful loading of the weights.
      See MODEL.WEIGHTS_INIT description in vissl/config/defaults.yaml for details.
      """
      params_from_file = self.config["MODEL"]["WEIGHTS_INIT"]
      init_weights_path = params_from_file["PARAMS_FILE"]
      assert (
          init_weights_path
      ), "Shouldn't call this when init_weight_path is empty"
      logging.info(f"Initializing model from: {init_weights_path}")
  
      if g_pathmgr.exists(init_weights_path):
          checkpoint = CheckpointLoader.load_and_broadcast_init_weights(
              checkpoint_path=init_weights_path,
              device=torch.device("cpu"),
          )
          logging.info(f"Checkpoint loaded: {init_weights_path}...")
          model.init_model_from_weights_params_file(
              self.config, checkpoint, strict=strict
          )
      return model
  
imports: import gc
  import logging
  import torch
  from classy_vision.generic.distributed_util import is_distributed_training_run
  from classy_vision.generic.util import copy_model_to_gpu
  from classy_vision.hooks import ClassyHook
  from classy_vision.losses import build_loss
  from classy_vision.meters import build_meter
  from classy_vision.optim import build_optimizer, build_optimizer_schedulers
  from classy_vision.tasks import ClassificationTask, register_task
  from classy_vision.tasks.classification_task import AmpType, BroadcastBuffersMode
  from fairscale.nn import FullyShardedDataParallel
  from iopath.common.file_io import g_pathmgr
  from torch.cuda.amp import GradScaler
  from vissl.config import AttrDict
  from vissl.data import build_dataloader, build_dataset, print_sampler_config
  from vissl.models import build_model, convert_sync_bn
  from vissl.optimizers import get_optimizer_param_groups
  from vissl.utils.activation_checkpointing import manual_gradient_reduction
  from vissl.utils.checkpoint import CheckpointLoader
  from vissl.utils.ema_model import ModelEmaV2
  from vissl.utils.misc import is_apex_available, is_fairscale_sharded_available
label_desc: Use image node_id 24 for calling the SelfSupervisionTask obj's underlying member method code with example usage: obj._restore_model_weights(model, strict) and returns: model