code: def initialise_from_vit(
      params: PyTree,
      restored_params: PyTree,
      config: ml_collections.ConfigDict,
      restored_model_cfg: ml_collections.ConfigDict,
      mbt_transformer_key: str,
      restore_output_proj: bool,
      prefix_path: Any,
  ) -> PyTree:
      """Initialize the parameters from a ViT like model."""
      init_config = config.init_from
      model_config = config.model
      dataset_config = config.dataset_configs
  
      if prefix_path:
          video_params = params[prefix_path]
      else:
          video_params = params
  
      # Start moving parameters, one-by-one and apply changes if needed
      for m_key, m_params in restored_params.items():
          if "ProjectionHeadAndClassifier" in m_key:
              for tm_key, tm_params in m_params.items():
                  if tm_key == "output_projection":
                      if restore_output_proj:
                          video_params[m_key][tm_key] = tm_params
                      else:
                          logging.info(
                              "Skipping output projection in restoring weights"
                          )
                          pass
                  elif tm_key == "pre_logits":
                      if model_config.representation_size is None:
                          # We don't have representation_size in the new model, so let's
                          # ignore if from the pretained model, in case it has it.
                          # Note, removing the key from the dictionary is necessary to
                          # prevent obscure errors from the Flax optimizer.
                          video_params.pop(tm_key, None)
                      else:
                          assert (
                              restored_model_cfg.model.representation_size
                          )
                          video_params[m_key][tm_key] = tm_params
  
          elif m_key in ["Transformer"]:
              for tm_key, tm_params in m_params.items():
                  if (
                      tm_key == "posembed_input"
                  ):  # Might need resolution change
                      init_posemb(
                          video_params[mbt_transformer_key],
                          m_params,
                          init_config,
                          model_config,
                          dataset_config,
                          restored_model_cfg,
                          "posembed_input",
                          prefix_path=prefix_path,
                      )
                      init_posemb(
                          video_params,
                          m_params,
                          init_config,
                          model_config,
                          dataset_config,
                          restored_model_cfg,
                          "bottleneck",
                          prefix_path=prefix_path,
                      )
                      for modality in model_config.modality_fusion:
                          if modality == "spectrogram":
                              modality_name = "spec"
                          else:
                              modality_name = modality
                          name = "_" + modality_name
                          init_posemb(
                              video_params[mbt_transformer_key],
                              m_params,
                              init_config,
                              model_config,
                              dataset_config,
                              restored_model_cfg,
                              "posembed_input" + name,
                              prefix_path=prefix_path,
                          )
                  elif "encoderblock" in tm_key:
                      logging.info("Loading encoder parameters.")
                      init_encoderblock(
                          video_params[mbt_transformer_key],
                          m_params,
                          tm_key,
                          model_config,
                      )
                  else:  # Other parameters of the Transformer encoder
                      video_params[mbt_transformer_key][
                          tm_key
                      ] = tm_params
          elif m_key == "embedding":
              init_embedding(
                  video_params,
                  m_params,
                  init_config,
                  model_config,
                  "embedding",
              )
              for modality in model_config.modality_fusion:
                  if modality == "spectrogram":
                      modality_name = "spec"
                  else:
                      modality_name = modality
                  name = "_" + modality_name
                  init_embedding(
                      video_params,
                      m_params,
                      init_config,
                      model_config,
                      "embedding" + name,
                  )
  
          else:
              mkey_found = False
              if m_key in params:
                  video_params[m_key] = m_params
                  mkey_found = True
              for modality in model_config.modality_fusion:
                  if modality == "spectrogram":
                      modality_name = "spec"
                  else:
                      modality_name = modality
                  mkey_name = "{}_".format(m_key) + modality_name
                  if mkey_name in params:
                      video_params[mkey_name] = m_params
                      mkey_found = True
              if not mkey_found:
                  logging.info(
                      "Skipping %s. In restored model but not in target",
                      m_key,
                  )
  
      return params
  
imports: import functools
  import re
  from typing import Any, Callable, Dict, Optional, Sequence, Tuple
  from absl import logging
  import flax
  import flax.linen
  import jax
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.common_lib import debug_utils
  from scenic.model_lib.base_models import base_model
  from scenic.model_lib.base_models import classification_model
  from scenic.model_lib.base_models import model_utils
  from scenic.model_lib.base_models.classification_model import ClassificationModel
  from scenic.model_lib.layers import nn_layers
  from scenic.projects.av_mae import model_utils
  from scenic.projects.baselines import vit
  from scenic.projects.mbt import model
  from scenic.projects.vivit import model_utils
  import scipy
label_desc: Use image node_id 6 for calling a global function with example usage: initialise_from_vit(params, restored_params, config, restored_model_cfg, mbt_transformer_key, restore_output_proj, prefix_path) and returns: params