code: def load_sagemaker_config(
      additional_config_paths: List[str] = None,
      s3_resource=None,
      repeat_log=False,
  ) -> dict:
      """Loads config files and merges them.
  
      By default, this method first searches for config files in the default locations
      defined by the SDK.
  
      Users can override the default admin and user config file paths using the
      ``SAGEMAKER_ADMIN_CONFIG_OVERRIDE`` and ``SAGEMAKER_USER_CONFIG_OVERRIDE`` environment
      variables, respectively.
  
      Additional config file paths can also be provided as a parameter.
  
      This method then:
          * Loads each config file, whether it is Amazon S3 or the local file system.
          * Validates the schema of the config files.
          * Merges the files in the same order.
  
      This method throws exceptions in the following cases:
          * ``jsonschema.exceptions.ValidationError``: Schema validation fails for one or more
            config files.
          * ``RuntimeError``: The method is unable to retrieve the list of all S3 files with the
            same prefix or is unable to retrieve the file.
          * ``ValueError``: There are no S3 files with the prefix when an S3 URI is provided.
          * ``ValueError``: There is no config.yaml file in the S3 bucket when an S3 URI is
            provided.
          * ``ValueError``: A file doesn't exist in a path that was specified by the user as
            part of an environment variable or additional configuration file path. This doesn't
            include the default config file locations.
  
      Args:
          additional_config_paths: List of config file paths.
              These paths can be one of the following. In the case of a directory, this method
              searches for a ``config.yaml`` file in that directory. This method does not perform a
              recursive search of folders in that directory.
  
                  * Local file path
                  * Local directory path
                  * S3 URI of the config file
                  * S3 URI of the directory containing the config file
  
              Note: S3 URI follows the format ``s3://<bucket>/<Key prefix>``
          s3_resource (boto3.resource("s3")): The Boto3 S3 resource. This is used to fetch
              config files from S3. If it is not provided but config files are present in S3,
              this method creates a default S3 resource. See `Boto3 Session documentation
              <https://boto3.amazonaws.com/v1/documentation/api\
              /latest/reference/core/session.html#boto3.session.Session.resource>`__.
              This argument is not needed if the config files are present in the local file system.
          repeat_log (bool): Whether the log with the same contents should be emitted.
              Default to ``False``
      """
      default_config_path = os.getenv(
          ENV_VARIABLE_ADMIN_CONFIG_OVERRIDE,
          _DEFAULT_ADMIN_CONFIG_FILE_PATH,
      )
      user_config_path = os.getenv(
          ENV_VARIABLE_USER_CONFIG_OVERRIDE,
          _DEFAULT_USER_CONFIG_FILE_PATH,
      )
      config_paths = [default_config_path, user_config_path]
      if additional_config_paths:
          config_paths += additional_config_paths
      config_paths = list(
          filter(lambda item: item is not None, config_paths)
      )
      merged_config = {}
  
      log_info = log_info_function
      if repeat_log:
          log_info = logger.info
  
      for file_path in config_paths:
          config_from_file = {}
          if file_path.startswith(S3_PREFIX):
              config_from_file = _load_config_from_s3(
                  file_path, s3_resource
              )
          else:
              try:
                  config_from_file = _load_config_from_file(file_path)
              except ValueError as error:
                  if file_path not in (
                      _DEFAULT_ADMIN_CONFIG_FILE_PATH,
                      _DEFAULT_USER_CONFIG_FILE_PATH,
                  ):
                      # Throw exception only when User provided file path is invalid.
                      # If there are no files in the Default config file locations, don't throw
                      # Exceptions.
                      raise
  
                  logger.debug(error)
          if config_from_file:
              validate_sagemaker_config(config_from_file)
              merge_dicts(merged_config, config_from_file)
              log_info(
                  "Fetched defaults config from location: %s", file_path
              )
          else:
              log_info(
                  "Not applying SDK defaults from location: %s",
                  file_path,
              )
  
      return merged_config
  
file_path: sagemaker-python-sdk/src/sagemaker/config/config.py
imports: from __future__ import absolute_import, annotations
  import pathlib
  import os
  from typing import List
  import boto3
  import yaml
  import jsonschema
  from platformdirs import site_config_dir, user_config_dir
  from botocore.utils import merge_dicts
  from six.moves.urllib.parse import urlparse
  from sagemaker.config.config_schema import SAGEMAKER_PYTHON_SDK_CONFIG_SCHEMA
  from sagemaker.config.config_utils import non_repeating_log_factory, get_sagemaker_config_logger
label_desc: Use image node_id 1 for calling a global function with example usage: load_sagemaker_config(additional_config_paths, s3_resource, repeat_log) and returns: merged_config