def METHOD_NAME():
    """Create an AWS session."""
    # Creating the session object is not thread-safe for boto3,
    # so we add a reentrant lock to synchronize the session creation.
    # Reference: https://github.com/boto/boto3/issues/1592
    # Retry 5 times by default for potential credential errors,
    # mentioned in
    # https://github.com/skypilot-org/skypilot/pull/1988
    if hasattr(_local, 'session'):
        return _local.METHOD_NAME
    max_attempts = 5
    attempt = 0
    backoff = common_utils.Backoff()
    err = None
    while attempt < max_attempts:
        try:
            with _session_creation_lock:
                # NOTE: we need the lock here to avoid
                # thread-safety issues when creating the session,
                # because Python module is a shared object,
                # and we are not sure the if code inside
                # boto3.session.Session() is thread-safe.
                _local.METHOD_NAME = boto3.METHOD_NAME.Session()
            return _local.METHOD_NAME
        except (botocore_exceptions().CredentialRetrievalError,
                botocore_exceptions().NoCredentialsError) as e:
            time.sleep(backoff.current_backoff())
            logger.info(f'Retry creating AWS session due to {e}.')
            err = e
            attempt += 1
    raise err