docs: def load_credentials(filename=None, account_type=None,
                       yaml_key=None, env_overwrite=True):
      """
      Handles credential management. Supports both YAML files and environment
      variables. A YAML file is preferred for simplicity and configureability.
      A YAML credential file should look something like this:
  
      .. code:: yaml
  
          <KEY>:
            endpoint: <FULL_URL_OF_ENDPOINT>
            username: <USERNAME>
            password: <PW>
            consumer_key: <KEY>
            consumer_secret: <SECRET>
            bearer_token: <TOKEN>
            account_type: <enterprise OR premium>
            extra_headers: 
              <MY_HEADER_KEY>: <MY_HEADER_VALUE>
  
      with the appropriate fields filled out for your account. The top-level key
      defaults to ``search_tweets_api`` but can be flexible.
  
      If a YAML file is not found or is missing keys, this function will check
      for this information in the environment variables that correspond to
  
      .. code: yaml
  
          SEARCHTWEETS_ENDPOINT
          SEARCHTWEETS_USERNAME
          SEARCHTWEETS_PASSWORD
          SEARCHTWEETS_BEARER_TOKEN
          SEARCHTWEETS_ACCOUNT_TYPE
          ...
  
      Again, set the variables that correspond to your account information and
      type. See the main documentation for details and more examples.
  
  
      Args:
          filename (str): pass a filename here if you do not want to use the
                          default ``~/.twitter_keys.yaml``
          account_type (str): your account type, "premium" or "enterprise". We
              will attempt to infer the account info if left empty.
          yaml_key (str): the top-level key in the YAML file that has your
              information. Defaults to ``search_tweets_api``.
          env_overwrite: any found environment variables will overwrite values
              found in a YAML file. Defaults to ``True``.
  
      Returns:
          dict: your access credentials.
  
      Example:
          >>> from searchtweets.api_utils import load_credentials
          >>> search_args = load_credentials(account_type="premium",
                  env_overwrite=False)
          >>> search_args.keys()
          dict_keys(['bearer_token', 'endpoint'])
          >>> import os
          >>> os.environ["SEARCHTWEETS_ENDPOINT"] = "https://endpoint"
          >>> os.environ["SEARCHTWEETS_USERNAME"] = "areallybadpassword"
          >>> os.environ["SEARCHTWEETS_PASSWORD"] = "<PW>"
          >>> load_credentials()
          {'endpoint': 'https://endpoint',
           'password': '<PW>',
           'username': 'areallybadpassword'}
  
      """
      yaml_key = yaml_key if yaml_key is not None else "search_tweets_api"
      filename = "~/.twitter_keys.yaml" if filename is None else filename
  
      yaml_vars = _load_yaml_credentials(filename=filename, yaml_key=yaml_key)
      if not yaml_vars:
          logger.warning("Error parsing YAML file; searching for "
                         "valid environment variables")
      env_vars = _load_env_credentials()
      merged_vars = (merge_dicts(yaml_vars, env_vars)
                     if env_overwrite
                     else merge_dicts(env_vars, yaml_vars))
      parsed_vars = _parse_credentials(merged_vars, account_type=account_type)
      return parsed_vars