code: def empty_sagemaker_session():
      ims = Mock(
          name="sagemaker_session",
          default_bucket_prefix=None,
      )
      ims.default_bucket = Mock(
          name="default_bucket", return_value=BUCKET_NAME
      )
      ims.sagemaker_runtime_client = Mock(name="sagemaker_runtime")
      ims.sagemaker_client.describe_endpoint = Mock(
          return_value=ENDPOINT_DESC
      )
      ims.sagemaker_client.describe_endpoint_config = Mock(
          return_value=ENDPOINT_CONFIG_DESC
      )
  
      ims.sagemaker_runtime_client.invoke_endpoint_async = Mock(
          name="invoke_endpoint_async",
          return_value={
              "OutputLocation": ASYNC_OUTPUT_LOCATION,
              "FailureLocation": ASYNC_FAILURE_LOCATION,
          },
      )
  
      async_inference_model_error = AsyncInferenceModelError(
          message="some error from model"
      )
  
      polling_timeout_error = PollingTimeoutError(
          message="Inference could still be running",
          output_path=ASYNC_OUTPUT_LOCATION,
          seconds=DEFAULT_WAITER_CONFIG.delay
          * DEFAULT_WAITER_CONFIG.max_attempts,
      )
  
      ims.s3_client = Mock(name="s3_client")
      ims.s3_client.get_object = Mock(
          name="get_object",
          side_effect=[
              async_inference_model_error,
              polling_timeout_error,
          ],
      )
  
      ims.s3_client.put_object = Mock(name="put_object")
  
      return ims
  
imports: from __future__ import absolute_import
  import pytest
  from mock import Mock
  from sagemaker.async_inference.waiter_config import WaiterConfig
  from sagemaker.predictor import Predictor
  from sagemaker.predictor_async import AsyncPredictor
  from sagemaker.exceptions import AsyncInferenceModelError, PollingTimeoutError
label_desc: Use image node_id 1 for calling a global function with example usage: empty_sagemaker_session() and returns: ims