code: def init_encoderblock(to_params, from_params, tm_key):
      """Initialize encoder_block_parameters."""
      # Explicitly enumerate over the keys in the encoder-block. Don't just
      # assign the dictionary. It is possible for the target model to
      # contain keys that are not in the restored model.
      for enc_key in from_params[tm_key].keys():
          restoring_params = False
          if tm_key in to_params:
              assert (
                  enc_key in to_params[tm_key]
              ), "%s not in to_params[%s]" % (enc_key, tm_key)
              to_params[tm_key][enc_key] = from_params[tm_key][enc_key]
              restoring_params = True
          if "%s_spectrogram" % tm_key in to_params:
              assert (
                  enc_key in to_params["%s_spectrogram" % tm_key]
              ), "%s not in to_params[%s]" % (
                  enc_key,
                  "%s_spectrogram" % tm_key,
              )
              to_params["%s_spectrogram" % tm_key][
                  enc_key
              ] = from_params[tm_key][enc_key]
              restoring_params = True
          if not restoring_params:
              logging.info("Warning: Not restoring encoder parameters.")
  
file_path: scenic/scenic/projects/mbt/model_utils.py
imports: from typing import Any
  from absl import logging
  import flax
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.common_lib import debug_utils
  from scenic.projects.vivit import model_utils
  import scipy
label_desc: Use image node_id 5 for calling a global function with example usage: init_encoderblock(to_params, from_params, tm_key) without return types