code: def _parse_s3_config(
      config_file_name: str,
      config_format: str | None = "boto",
      profile: str | None = None,
  ) -> tuple[str | None, str | None]:
      """Parse a config file for S3 credentials.
  
      Can currently parse boto, s3cmd.conf and AWS SDK config formats.
  
      :param config_file_name: path to the config file
      :param config_format: config type. One of "boto", "s3cmd" or "aws".
          Defaults to "boto"
      :param profile: profile name in AWS type config file
      """
      warnings.warn(
          "Use local credentials file is never documented and well tested. "
          "Obtain credentials by this way deprecated and will be removed in a future releases.",
          AirflowProviderDeprecationWarning,
          stacklevel=4,
      )
  
      import configparser
  
      config = configparser.ConfigParser()
      try:
          if config.read(config_file_name):  # pragma: no cover
              sections = config.sections()
          else:
              raise AirflowException(
                  f"Couldn't read {config_file_name}"
              )
      except Exception as e:
          raise AirflowException(
              "Exception when parsing %s: %s",
              config_file_name,
              e.__class__.__name__,
          )
      # Setting option names depending on file format
      if config_format is None:
          config_format = "boto"
      conf_format = config_format.lower()
      if conf_format == "boto":  # pragma: no cover
          if profile is not None and "profile " + profile in sections:
              cred_section = "profile " + profile
          else:
              cred_section = "Credentials"
      elif conf_format == "aws" and profile is not None:
          cred_section = profile
      else:
          cred_section = "default"
      # Option names
      if conf_format in ("boto", "aws"):  # pragma: no cover
          key_id_option = "aws_access_key_id"
          secret_key_option = "aws_secret_access_key"
      else:
          key_id_option = "access_key"
          secret_key_option = "secret_key"
      # Actual Parsing
      if cred_section not in sections:
          raise AirflowException(
              "This config file format is not recognized"
          )
      else:
          try:
              access_key = config.get(cred_section, key_id_option)
              secret_key = config.get(cred_section, secret_key_option)
              mask_secret(secret_key)
          except Exception:
              raise AirflowException(
                  "Option Error in parsing s3 config file"
              )
          return access_key, secret_key
  
imports: from __future__ import annotations
  import json
  import warnings
  from copy import deepcopy
  from dataclasses import MISSING, InitVar, dataclass, field, fields
  from functools import cached_property
  from typing import TYPE_CHECKING, Any
  from botocore import UNSIGNED
  from botocore.config import Config
  from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
  from airflow.providers.amazon.aws.utils import trim_none_values
  from airflow.utils.log.logging_mixin import LoggingMixin
  from airflow.utils.log.secrets_masker import mask_secret
  from airflow.utils.types import NOTSET, ArgNotSet
label_desc: Use image node_id 1 for calling a global function with example usage: _parse_s3_config(config_file_name, config_format, profile) and returns: access_key,  secret_key