code: def configure(
      models: Optional[LibraryModelsType] = None,
      configuration: Optional[
          Mapping[str, Union[Dict[str, Any], ModelConfiguration]]
      ] = None,
  ) -> Dict[str, ModelConfiguration]:
      if not models:
          models = os.environ.get("MODELKIT_DEFAULT_PACKAGE")
  
      conf = _configurations_from_objects(models) if models else {}
      if configuration:
          for key in set(conf.keys()) & set(configuration.keys()):
              if key in configuration:
                  # We extract configuration[key] in a variable to help mypy infer correct
                  # type after isinstance checks
                  conf_value = configuration[key]
                  if isinstance(conf_value, ModelConfiguration):
                      conf[key] = conf_value
                  elif isinstance(conf_value, dict):
                      conf[key] = ModelConfiguration(
                          **{**conf[key].model_dump(), **conf_value}
                      )
          for key in set(configuration.keys()) - set(conf.keys()):
              conf_value = configuration[key]
              if isinstance(conf_value, ModelConfiguration):
                  conf[key] = conf_value
              elif isinstance(conf_value, dict):
                  conf[key] = ModelConfiguration(**conf_value)
      return conf
  
file_path: modelkit/modelkit/core/model_configuration.py
imports: import importlib
  import inspect
  import os
  import pkgutil
  from collections import ChainMap
  from types import ModuleType
  from typing import Any, Dict, List, Mapping, Optional, Set, Type, Union
  import pydantic
  from structlog import get_logger
  from modelkit.core.model import Asset
  from modelkit.core.settings import ModelkitSettings
  from modelkit.core.types import LibraryModelsType
label_desc: Use image node_id 4 for calling a global function with example usage: configure(models, configuration) and returns: conf