code: def gcloud_credentials(
      credentials_path: Optional[str] = None,
  ) -> Optional[Credentials]:
      credentials = None
  
      if credentials_path is not None:
          credentials = (
              service_account.Credentials.from_service_account_file(
                  credentials_path
              )
          )
      else:
          # attempt to fetch credentials acquired via `gcloud auth login`. If this
          # fails, the following API object will attempt to use application default
          # credentials.
          credentials = gcloud_auth_credentials()
  
          return credentials
  
imports: from subprocess import CalledProcessError, check_output
  from typing import Optional
  from google.oauth2 import service_account
  from google.oauth2.credentials import Credentials
label_desc: Use image node_id 3 for calling a global function with example usage: gcloud_credentials(credentials_path) and returns: credentials