code: def _aws_credentials(session):
      """Provides the AWS credentials of the session as a paired list of strings.
  
      These can be used to set environment variables on command execution.
  
      Args:
          session:
      """
      try:
          creds = session.get_credentials()
          access_key = creds.access_key
          secret_key = creds.secret_key
          token = creds.token
  
          # The presence of a token indicates the credentials are short-lived and as such are risky
          # to be used as they might expire while running.
          # Long-lived credentials are available either through
          # 1. boto session
          # 2. EC2 Metadata Service (SageMaker Notebook instances or EC2 instances with roles
          #       attached them)
          # Short-lived credentials available via boto session are permitted to support running on
          # machines with no EC2 Metadata Service but a warning is provided about their danger
          if token is None:
              logger.info(
                  "Using the long-lived AWS credentials found in session"
              )
              return [
                  "AWS_ACCESS_KEY_ID=%s" % (str(access_key)),
                  "AWS_SECRET_ACCESS_KEY=%s" % (str(secret_key)),
              ]
          if (
              _use_short_lived_credentials()
              or not _aws_credentials_available_in_metadata_service()
          ):
              logger.warning(
                  "Using the short-lived AWS credentials found in session. They might expire while "
                  "running."
              )
              return [
                  "AWS_ACCESS_KEY_ID=%s" % (str(access_key)),
                  "AWS_SECRET_ACCESS_KEY=%s" % (str(secret_key)),
                  "AWS_SESSION_TOKEN=%s" % (str(token)),
              ]
          logger.info(
              "No AWS credentials found in session but credentials from EC2 Metadata Service are "
              "available."
          )
          return None
      except Exception as e:  # pylint: disable=broad-except
          logger.info("Could not get AWS credentials: %s", e)
  
      return None
  
imports: from __future__ import absolute_import, annotations
  import base64
  import copy
  import errno
  import json
  import logging
  import os
  import platform
  import random
  import re
  import shlex
  import shutil
  import string
  import subprocess
  import sys
  import tarfile
  import tempfile
  from distutils.spawn import find_executable
  from threading import Thread
  from typing import Dict, List
  from six.moves.urllib.parse import urlparse
  import sagemaker
  from sagemaker.config.config_schema import CONTAINER_CONFIG, LOCAL
  import sagemaker.local.data
  import sagemaker.local.utils
  import sagemaker.utils
label_desc: Use image node_id 6 for calling a global function with example usage: _aws_credentials(session) and returns: None, None, list, list