code: def test_get_s3_client_region_name_set_correctly(
      s3_artifact_root, client_throws
  ):
      region_name = "us_random_region_42"
      with mock.patch("boto3.client") as mock_get_s3_client:
          from botocore.exceptions import ClientError
  
          s3_client_mock = mock.Mock()
          mock_get_s3_client.return_value = s3_client_mock
          if client_throws:
              error = ClientError(
                  {
                      "Error": {"Code": "403", "Message": "Forbidden"},
                      "ResponseMetadata": {
                          "HTTPHeaders": {
                              "x-amz-bucket-region": region_name
                          },
                      },
                  },
                  "head_bucket",
              )
              s3_client_mock.head_bucket.side_effect = error
          else:
              s3_client_mock.head_bucket.return_value = {
                  "BucketRegion": region_name
              }
  
          repo = OptimizedS3ArtifactRepository(
              posixpath.join(s3_artifact_root, "some/path")
          )
          repo._get_s3_client()
  
          mock_get_s3_client.assert_called_with(
              "s3",
              config=ANY,
              endpoint_url=ANY,
              verify=None,
              aws_access_key_id=None,
              aws_secret_access_key=None,
              aws_session_token=None,
              region_name=region_name,
          )
  
file_path: mlflow/tests/store/artifact/test_optimized_s3_artifact_repo.py
imports: import os
  import posixpath
  from datetime import datetime
  from unittest import mock
  from unittest.mock import ANY
  import pytest
  from mlflow.protos.service_pb2 import FileInfo
  from mlflow.store.artifact.optimized_s3_artifact_repo import OptimizedS3ArtifactRepository
  from mlflow.store.artifact.s3_artifact_repo import _MAX_CACHE_SECONDS, _cached_get_s3_client
  from tests.helper_functions import set_boto_credentials
label_desc: Use image node_id 5 for calling a global function with example usage: test_get_s3_client_region_name_set_correctly(s3_artifact_root, client_throws) without return types