code: def load_weights_from_hdf5_group_by_name(
      filepath, weights_replacement
  ):
      with h5py.File(filepath, "r") as f:
          if "layer_names" not in f.attrs and "model_weights" in f:
              f = f["model_weights"]
  
          # New file format.
          layer_names = load_attributes_from_hdf5_group(
              f, "layer_names"
          )
          weight_lookup = {}
          for name in layer_names:
              g = f[name]
              for name in load_attributes_from_hdf5_group(
                  g, "weight_names"
              ):
                  output_name = name
                  for fro, to in weights_replacement:
                      output_name = output_name.replace(fro, to)
                  if output_name in weight_lookup and not np.all(
                      weight_lookup[output_name] == g[name]
                  ):
                      raise ValueError(
                          "Duplicate names found in weight mapping for {}, check your weight replacement rules.".format(
                              output_name
                          )
                      )
                  weight_lookup[output_name] = np.asarray(g[name])
      return weight_lookup
  
imports: import h5py
  import numpy
  import joblib
  import os
  import tqdl
  import logging
  import tensorflow
  import unicodedata
  import string
  from tensorflow.python.keras.saving.hdf5_format import load_attributes_from_hdf5_group
  from finetune.util.download import FINETUNE_BASE_FOLDER
  from finetune.util.shapes import lengths_from_eos_idx
  from finetune.util.tokenization import normalize_nfkc, WEIRD_SPM_CHAR
  from finetune.encoding.input_encoder import BaseEncoder
  from finetune.encoding.input_encoder import EncodedOutput
  from finetune.base_models import SourceModel
  from finetune.optimizers.recompute_grads import recompute_grads_w_kwargs
  from finetune.util.featurizer_fusion import fused_featurizer
  from tensorflow.python.util import tf_inspect
  from tensorflow.python.keras.utils import tf_utils
  from tensorflow.keras.layers import Embedding
  from transformers.models.longformer.modeling_tf_longformer import TFLongformerSelfAttention
label_desc: Use image node_id 4 for calling a global function with example usage: load_weights_from_hdf5_group_by_name(filepath, weights_replacement) and returns: weight_lookup