code: def test_prepare_history_server_env_variables(
      mock_is_notebook_instance,
      mock_config_aws_credentials,
      mock_get_notebook_instance_domain,
      py_spark_processor,
  ):
      mock_is_notebook_instance.return_value = True
      mock_get_notebook_instance_domain.return_value = "domain"
  
      result = py_spark_processor._prepare_history_server_env_variables(
          SPARK_EVENT_LOGS_S3_URI
      )
      assert len(result) == 3
      assert result[_HistoryServer.arg_remote_domain_name] == "domain"
      assert (
          result[_HistoryServer.arg_event_logs_s3_uri]
          == SPARK_EVENT_LOGS_S3_URI
      )
      assert result["AWS_REGION"] == REGION
  
      mock_is_notebook_instance.return_value = False
      mock_get_notebook_instance_domain.return_value = "domain"
      mock_config_aws_credentials.return_value = {
          "AWS_ACCESS_KEY_ID": "123",
          "AWS_SECRET_ACCESS_KEY": "456",
          "AWS_SESSION_TOKEN": "789",
      }
      result = py_spark_processor._prepare_history_server_env_variables(
          SPARK_EVENT_LOGS_S3_URI
      )
      assert len(result) == 5
      assert (
          result[_HistoryServer.arg_event_logs_s3_uri]
          == SPARK_EVENT_LOGS_S3_URI
      )
      assert result["AWS_ACCESS_KEY_ID"] == "123"
      assert result["AWS_SECRET_ACCESS_KEY"] == "456"
      assert result["AWS_SESSION_TOKEN"] == "789"
      assert result["AWS_REGION"] == REGION
  
      py_spark_processor._spark_event_logs_s3_uri = (
          SPARK_EVENT_LOGS_S3_URI
      )
      mock_is_notebook_instance.return_value = True
      mock_get_notebook_instance_domain.return_value = "domain"
      result = py_spark_processor._prepare_history_server_env_variables(
          None
      )
      assert len(result) == 6
      assert result[_HistoryServer.arg_remote_domain_name] == "domain"
      assert (
          result[_HistoryServer.arg_event_logs_s3_uri]
          == SPARK_EVENT_LOGS_S3_URI
      )
      assert result["AWS_REGION"] == REGION
  
imports: from __future__ import absolute_import
  import pathlib
  import subprocess
  import tempfile
  from io import BytesIO
  from typing import Generator
  from unittest.case import TestCase
  from unittest.mock import MagicMock, Mock, call, mock_open, patch
  import pytest
  from sagemaker.processing import ProcessingInput, ProcessingOutput
  from sagemaker.session_settings import SessionSettings
  from sagemaker.spark.processing import PySparkProcessor, SparkJarProcessor, _SparkProcessorBase, _HistoryServer, FileType, SparkConfigUtils
label_desc: Use image node_id 19 for calling a global function with example usage: test_prepare_history_server_env_variables(mock_is_notebook_instance, mock_config_aws_credentials, mock_get_notebook_instance_domain, py_spark_processor) without return types