code: def init_encoderblock(to_params, from_params, tm_key, 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 = config.model.attention_config.type
      for enc_key in from_params[tm_key].keys():
          if attention_type in [
              "spacetime",
              "factorized_encoder",
              "factorized_dot_product_attention",
          ]:
              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]
  
          elif attention_type == "factorized_transformer_block":
              if config.init_from.get("init_spatial_transformer", True):
                  to_params[tm_key]["encoderblock_space"] = from_params
              if config.init_from.get(
                  "init_temporal_transformer", True
              ):
                  to_params[tm_key]["encoderblock_time"] = from_params
  
          elif attention_type == "factorized_self_attention_block":
              if enc_key in to_params[tm_key]:
                  # We have an exact match. This would happen when loading weights from
                  # another factorised encoder model.
                  to_params[tm_key][enc_key] = from_params[tm_key][
                      enc_key
                  ]
                  logging.info(
                      "%s: Initialising %s directly from restored model",
                      tm_key,
                      enc_key,
                  )
              elif enc_key == "MultiHeadDotProductAttention_0":
                  if config.init_from.get(
                      "init_spatial_transformer", True
                  ):
                      logging.info(
                          "%s: Initialising spatial transformer from "
                          "pretrained weights",
                          tm_key,
                      )
                      to_params[tm_key][
                          "MultiHeadDotProductAttention_space"
                      ] = from_params[tm_key][enc_key].copy()
                  if config.init_from.get(
                      "init_temporal_transformer", True
                  ):
                      logging.info(
                          "%s: Initialising temporal transformer from "
                          "pretrained weights",
                          tm_key,
                      )
                      to_params[tm_key][
                          "MultiHeadDotProductAttention_time"
                      ] = from_params[tm_key][enc_key].copy()
              elif enc_key == "LayerNorm_0":
                  to_params[tm_key]["LayerNorm_space"] = from_params[
                      tm_key
                  ][enc_key]
                  if config.init_from.get(
                      "init_temporal_layer_norm", False
                  ):
                      logging.info(
                          "%s: %s Initialising temporal layer norm from "
                          "restored model",
                          tm_key,
                          enc_key,
                      )
              # The following part could be made more generic.
              elif enc_key == "LayerNorm_1":
                  to_params[tm_key]["LayerNorm_mlp"] = from_params[
                      tm_key
                  ][enc_key]
              elif enc_key == "MlpBlock_0":
                  to_params[tm_key]["MlpBlock"] = from_params[tm_key][
                      enc_key
                  ]
              else:
                  logging.info(
                      'Key "%s" in restored model\'s encoder block not in '
                      "target model",
                      enc_key,
                  )
          else:
              raise ValueError(
                  f"Unknown attention type {attention_type}"
              )
  
imports: from typing import Any, Optional, Tuple
  from absl import logging
  import flax
  from flax.linen import linear
  from flax.training import common_utils
  import jax
  import jax.numpy
  import ml_collections
  import numpy
  from scenic.common_lib import debug_utils
  from scenic.model_lib.base_models import model_utils
  import scipy
label_desc: Use image node_id 11 for calling a global function with example usage: init_encoderblock(to_params, from_params, tm_key, config) without return types