code: def init_encoderblock(to_params, from_params, tm_key, model_config):
      """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.
      attention_type = model_config.attention_config.type
      for enc_key in from_params[tm_key].keys():
          if attention_type in [
              "spacetime",
              "factorized_encoder",
              "factorized_dot_product_attention",
          ]:
              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
              for modality in model_config.modality_fusion:
                  if modality == "spectrogram":
                      modality_name = "spec"
                  else:
                      modality_name = modality
                  tmkey_name = "{}_".format(tm_key) + modality_name
                  if tmkey_name in to_params:
                      assert (
                          enc_key in to_params[tmkey_name]
                      ), "%s not in to_params[%s]" % (
                          enc_key,
                          tmkey_name,
                      )
                      to_params[tmkey_name][enc_key] = from_params[
                          tm_key
                      ][enc_key]
                      restoring_params = True
              if not restoring_params:
                  logging.info(
                      "Warning: Not restoring encoder parameters."
                  )
  
          elif attention_type == "factorized_transformer_block":
              raise NotImplementedError(
                  "Factorized attention not implemented."
              )
          else:
              raise ValueError(
                  f"Unknown attention type {attention_type}"
              )
  
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 13 for calling a global function with example usage: init_encoderblock(to_params, from_params, tm_key, model_config) without return types