code: def save_weights_to_hdf5_group(f, model):
      """Saves the weights of a list of layers to a HDF5 group.
  
      Args:
          f: HDF5 group.
          model: Model instance.
      """
      from keras import __version__ as keras_version
  
      save_attributes_to_hdf5_group(
          f,
          "layer_names",
          [layer.name.encode("utf8") for layer in model.layers],
      )
      f.attrs["backend"] = backend.backend().encode("utf8")
      f.attrs["keras_version"] = str(keras_version).encode("utf8")
  
      # Sort model layers by layer name to ensure that group names are strictly
      # growing to avoid prefix issues.
      for layer in sorted(model.layers, key=lambda x: x.name):
          g = f.create_group(layer.name)
          weights = _legacy_weights(layer)
          save_subset_weights_to_hdf5_group(g, weights)
      weights = list(
          v
          for v in model._trainable_variables
          + model._non_trainable_variables
          if v in model.weights
      )
      g = f.create_group("top_level_model_weights")
      save_subset_weights_to_hdf5_group(g, weights)
  
imports: import json
  import os
  import warnings
  import numpy
  from absl import logging
  from keras import backend
  from keras import optimizers
  from keras.backend.common import global_state
  from keras.legacy.saving import json_utils
  from keras.legacy.saving import saving_options
  from keras.legacy.saving import saving_utils
  from keras.saving import object_registration
  from keras.utils import io_utils
label_desc: Use image node_id 3 for calling a global function with example usage: save_weights_to_hdf5_group(f, model) without return types