code: def provide_gcp_credentials(
      key_file_path: str | None = None,
      key_file_dict: dict | None = None,
  ) -> Generator[None, None, None]:
      """
      Context manager that provides Google Cloud credentials for Application Default Credentials (ADC).
  
      .. seealso::
          `Application Default Credentials (ADC) strategy`__.
  
      It can be used to provide credentials for external programs (e.g. gcloud) that expect authorization
      file in ``GOOGLE_APPLICATION_CREDENTIALS`` environment variable.
  
      :param key_file_path: Path to file with Google Cloud Service Account .json file.
      :param key_file_dict: Dictionary with credentials.
  
      __ https://cloud.google.com/docs/authentication/production
      """
      if not key_file_path and not key_file_dict:
          raise ValueError(
              "Please provide `key_file_path` or `key_file_dict`."
          )
  
      if key_file_path and key_file_path.endswith(".p12"):
          raise AirflowException(
              "Legacy P12 key file are not supported, use a JSON key file."
          )
  
      with tempfile.NamedTemporaryFile(mode="w+t") as conf_file:
          if not key_file_path and key_file_dict:
              conf_file.write(json.dumps(key_file_dict))
              conf_file.flush()
              key_file_path = conf_file.name
          if key_file_path:
              with patch_environ({CREDENTIALS: key_file_path}):
                  yield
          else:
              # We will use the default service account credentials.
              yield
  
imports: from __future__ import annotations
  import json
  import logging
  import os
  import tempfile
  from contextlib import ExitStack, contextmanager
  from typing import Collection, Generator, Sequence
  from urllib.parse import urlencode
  import google.auth
  import google.auth.credentials
  import google.oauth2.service_account
  from google.auth import impersonated_credentials
  from google.auth.environment_vars import CREDENTIALS, LEGACY_PROJECT, PROJECT
  from airflow.exceptions import AirflowException
  from airflow.providers.google.cloud._internal_client.secret_manager_client import _SecretManagerClient
  from airflow.utils.log.logging_mixin import LoggingMixin
  from airflow.utils.process_utils import patch_environ
label_desc: Use image node_id 2 for calling a global function with example usage: provide_gcp_credentials(key_file_path, key_file_dict) without return types