code: def load_weights(model, filepath, skip_mismatch=False, **kwargs):
      if str(filepath).endswith(".keras"):
          if kwargs:
              raise ValueError(f"Invalid keyword arguments: {kwargs}")
          saving_lib.load_weights_only(
              model, filepath, skip_mismatch=skip_mismatch
          )
      elif str(filepath).endswith(".weights.h5"):
          if kwargs:
              raise ValueError(f"Invalid keyword arguments: {kwargs}")
          saving_lib.load_weights_only(
              model, filepath, skip_mismatch=skip_mismatch
          )
      elif str(filepath).endswith(".h5") or str(filepath).endswith(
          ".hdf5"
      ):
          by_name = kwargs.pop("by_name", False)
          if kwargs:
              raise ValueError(f"Invalid keyword arguments: {kwargs}")
          if not h5py:
              raise ImportError(
                  "Loading a H5 file requires `h5py` to be installed."
              )
          with h5py.File(filepath, "r") as f:
              if "layer_names" not in f.attrs and "model_weights" in f:
                  f = f["model_weights"]
              if by_name:
                  legacy_h5_format.load_weights_from_hdf5_group_by_name(
                      f, model, skip_mismatch
                  )
              else:
                  legacy_h5_format.load_weights_from_hdf5_group(
                      f, model
                  )
      else:
          raise ValueError(
              f"File format not supported: filepath={filepath}. "
              "Keras 3 only supports V3 `.keras` and `.weights.h5` "
              "files, or legacy V1/V2 `.h5` files."
          )
  
file_path: keras/keras/saving/saving_api.py
imports: import os
  import zipfile
  from absl import logging
  from keras.api_export import keras_export
  from keras.legacy.saving import legacy_h5_format
  from keras.saving import saving_lib
  from keras.utils import file_utils
  from keras.utils import io_utils
label_desc: Use image node_id 3 for calling a global function with example usage: load_weights(model, filepath, skip_mismatch) without return types