code: def test_jumpstart_cache_handles_boto3_client_errors():
      # Testing get_object
      cache = JumpStartModelsCache(s3_bucket_name="some_bucket")
      stubbed_s3_client = Stubber(cache._s3_client)
      stubbed_s3_client.add_client_error(
          "get_object", http_status_code=404
      )
      stubbed_s3_client.activate()
      with pytest.raises(botocore.exceptions.ClientError):
          cache.get_header(
              model_id="tensorflow-ic-imagenet-inception-v3-classification-4",
              semantic_version_str="*",
          )
  
      cache = JumpStartModelsCache(s3_bucket_name="some_bucket")
      stubbed_s3_client = Stubber(cache._s3_client)
      stubbed_s3_client.add_client_error(
          "get_object", service_error_code="AccessDenied"
      )
      stubbed_s3_client.activate()
      with pytest.raises(botocore.exceptions.ClientError):
          cache.get_header(
              model_id="tensorflow-ic-imagenet-inception-v3-classification-4",
              semantic_version_str="*",
          )
  
      cache = JumpStartModelsCache(s3_bucket_name="some_bucket")
      stubbed_s3_client = Stubber(cache._s3_client)
      stubbed_s3_client.add_client_error(
          "get_object", service_error_code="EndpointConnectionError"
      )
      stubbed_s3_client.activate()
      with pytest.raises(botocore.exceptions.ClientError):
          cache.get_header(
              model_id="tensorflow-ic-imagenet-inception-v3-classification-4",
              semantic_version_str="*",
          )
  
      # Testing head_object:
      mock_now = datetime.datetime.fromtimestamp(1636730651.079551)
      with patch("datetime.datetime") as mock_datetime:
          mock_manifest_json = json.dumps(
              [
                  {
                      "model_id": "pytorch-ic-imagenet-inception-v3-classification-4",
                      "version": "2.0.0",
                      "min_version": "2.49.0",
                      "spec_key": "community_models_specs/pytorch-ic-"
                      "imagenet-inception-v3-classification-4/specs_v2.0.0.json",
                  }
              ]
          )
  
          get_object_mocked_response = {
              "Body": botocore.response.StreamingBody(
                  io.BytesIO(bytes(mock_manifest_json, "utf-8")),
                  content_length=len(mock_manifest_json),
              ),
              "ETag": "etag",
          }
  
          mock_datetime.now.return_value = mock_now
  
          cache1 = JumpStartModelsCache(
              s3_bucket_name="some_bucket",
              s3_cache_expiration_horizon=datetime.timedelta(hours=1),
          )
          stubbed_s3_client1 = Stubber(cache1._s3_client)
  
          stubbed_s3_client1.add_response(
              "get_object", copy.deepcopy(get_object_mocked_response)
          )
          stubbed_s3_client1.activate()
          cache1.get_header(
              model_id="pytorch-ic-imagenet-inception-v3-classification-4",
              semantic_version_str="*",
          )
  
          mock_datetime.now.return_value += datetime.timedelta(weeks=1)
  
          stubbed_s3_client1.add_client_error(
              "head_object", http_status_code=404
          )
          with pytest.raises(botocore.exceptions.ClientError):
              cache1.get_header(
                  model_id="pytorch-ic-imagenet-inception-v3-classification-4",
                  semantic_version_str="*",
              )
  
          cache2 = JumpStartModelsCache(
              s3_bucket_name="some_bucket",
              s3_cache_expiration_horizon=datetime.timedelta(hours=1),
          )
          stubbed_s3_client2 = Stubber(cache2._s3_client)
  
          stubbed_s3_client2.add_response(
              "get_object", copy.deepcopy(get_object_mocked_response)
          )
          stubbed_s3_client2.activate()
          cache2.get_header(
              model_id="pytorch-ic-imagenet-inception-v3-classification-4",
              semantic_version_str="*",
          )
  
          mock_datetime.now.return_value += datetime.timedelta(weeks=1)
  
          stubbed_s3_client2.add_client_error(
              "head_object", service_error_code="AccessDenied"
          )
          with pytest.raises(botocore.exceptions.ClientError):
              cache2.get_header(
                  model_id="pytorch-ic-imagenet-inception-v3-classification-4",
                  semantic_version_str="*",
              )
  
          cache3 = JumpStartModelsCache(
              s3_bucket_name="some_bucket",
              s3_cache_expiration_horizon=datetime.timedelta(hours=1),
          )
          stubbed_s3_client3 = Stubber(cache3._s3_client)
  
          stubbed_s3_client3.add_response(
              "get_object", copy.deepcopy(get_object_mocked_response)
          )
          stubbed_s3_client3.activate()
          cache3.get_header(
              model_id="pytorch-ic-imagenet-inception-v3-classification-4",
              semantic_version_str="*",
          )
  
          mock_datetime.now.return_value += datetime.timedelta(weeks=1)
  
          stubbed_s3_client3.add_client_error(
              "head_object",
              service_error_code="EndpointConnectionError",
          )
          with pytest.raises(botocore.exceptions.ClientError):
              cache3.get_header(
                  model_id="pytorch-ic-imagenet-inception-v3-classification-4",
                  semantic_version_str="*",
              )
  
imports: from __future__ import absolute_import
  import copy
  import datetime
  import io
  import json
  from unittest.mock import Mock, call, mock_open
  from botocore.stub import Stubber
  import botocore
  from mock.mock import MagicMock
  import pytest
  from mock import patch
  from sagemaker.jumpstart.cache import JUMPSTART_DEFAULT_MANIFEST_FILE_S3_KEY, JumpStartModelsCache
  from sagemaker.jumpstart.constants import ENV_VARIABLE_JUMPSTART_MANIFEST_LOCAL_ROOT_DIR_OVERRIDE, ENV_VARIABLE_JUMPSTART_SPECS_LOCAL_ROOT_DIR_OVERRIDE
  from sagemaker.jumpstart.types import JumpStartModelHeader, JumpStartModelSpecs, JumpStartVersionedModelId
  from tests.unit.sagemaker.jumpstart.utils import get_spec_from_base_spec, patched_retrieval_function
  from tests.unit.sagemaker.jumpstart.constants import BASE_MANIFEST, BASE_SPEC
  from sagemaker.jumpstart.utils import get_jumpstart_content_bucket
label_desc: Use image node_id 4 for calling a global function with example usage: test_jumpstart_cache_handles_boto3_client_errors() without return types