code: def authenticate(creds: AnyAWSCreds, region: str) -> Session:
      session = get_session(creds=creds, region=region)
      validate_credentials(session)
      return session
  
file_path: dstack/src/dstack/_internal/core/backends/aws/auth.py
imports: import boto3.session
  import botocore.exceptions
  from boto3.session import Session
  from dstack._internal.core.errors import BackendAuthError
  from dstack._internal.core.models.backends.aws import AnyAWSCreds, AWSAccessKeyCreds
label_desc: Use image node_id 1 for calling a global function with example usage: authenticate(creds, region) and returns: session