code: def _extend_spark_config_to_request(
      request_dict: Dict,
      job_settings: _JobSettings,
      s3_base_uri: str,
  ) -> Dict:
      """Extend the create training job request with spark configurations.
  
      Args:
          request_dict (Dict): create training job request dict.
          job_settings (_JobSettings): the job settings.
          s3_base_uri (str): S3 location that the Spark dependencies will be uploaded to.
      """
      spark_config = job_settings.spark_config
  
      if not spark_config:
          return request_dict
  
      extended_request = request_dict.copy()
      container_entrypoint = extended_request["AlgorithmSpecification"][
          "ContainerEntrypoint"
      ]
  
      (
          submit_jars_s3_paths,
          submit_py_files_s3_paths,
          submit_files_s3_path,
          config_file_s3_uri,
      ) = _prepare_and_upload_spark_dependent_files(
          spark_config=spark_config,
          s3_base_uri=s3_base_uri,
          s3_kms_key=job_settings.s3_kms_key,
          sagemaker_session=job_settings.sagemaker_session,
      )
  
      input_data_config = extended_request["InputDataConfig"]
  
      if config_file_s3_uri:
          input_data_config.append(
              dict(
                  ChannelName=SPARK_CONF_CHANNEL_NAME,
                  DataSource={
                      "S3DataSource": {
                          "S3Uri": config_file_s3_uri,
                          "S3DataType": "S3Prefix",
                      }
                  },
              )
          )
  
      for input_channel in extended_request["InputDataConfig"]:
          s3_data_source = input_channel["DataSource"].get(
              "S3DataSource", None
          )
          if s3_data_source:
              s3_data_source[
                  "S3DataDistributionType"
              ] = "FullyReplicated"
  
      if spark_config.spark_event_logs_uri:
          container_entrypoint.extend(
              [
                  "--spark-event-logs-s3-uri",
                  spark_config.spark_event_logs_uri,
              ]
          )
  
      if submit_jars_s3_paths:
          container_entrypoint.extend(["--jars", submit_jars_s3_paths])
  
      if submit_py_files_s3_paths:
          container_entrypoint.extend(
              ["--py-files", submit_py_files_s3_paths]
          )
  
      if submit_files_s3_path:
          container_entrypoint.extend(["--files", submit_files_s3_path])
  
      if spark_config:
          container_entrypoint.extend([SPARK_APP_SCRIPT_PATH])
  
      return extended_request
  
imports: from __future__ import absolute_import
  import dataclasses
  import os
  import re
  import shutil
  import sys
  import json
  import secrets
  from typing import Callable, Dict, List, Optional, Tuple, Union, TYPE_CHECKING
  from urllib.parse import urlparse
  from io import BytesIO
  from sagemaker.config.config_schema import REMOTE_FUNCTION_ENVIRONMENT_VARIABLES, REMOTE_FUNCTION_IMAGE_URI, REMOTE_FUNCTION_DEPENDENCIES, REMOTE_FUNCTION_PRE_EXECUTION_COMMANDS, REMOTE_FUNCTION_PRE_EXECUTION_SCRIPT, REMOTE_FUNCTION_INCLUDE_LOCAL_WORKDIR, REMOTE_FUNCTION_INSTANCE_TYPE, REMOTE_FUNCTION_JOB_CONDA_ENV, REMOTE_FUNCTION_ROLE_ARN, REMOTE_FUNCTION_S3_ROOT_URI, REMOTE_FUNCTION_S3_KMS_KEY_ID, REMOTE_FUNCTION_VOLUME_KMS_KEY_ID, REMOTE_FUNCTION_TAGS, REMOTE_FUNCTION_VPC_CONFIG_SUBNETS, REMOTE_FUNCTION_VPC_CONFIG_SECURITY_GROUP_IDS, REMOTE_FUNCTION_ENABLE_INTER_CONTAINER_TRAFFIC_ENCRYPTION
  from sagemaker.experiments._run_context import _RunContext
  from sagemaker.experiments.run import Run
  from sagemaker.image_uris import get_base_python_image_uri
  from sagemaker import image_uris
  from sagemaker.remote_function.checkpoint_location import CheckpointLocation
  from sagemaker.session import get_execution_role, _logs_for_job, Session
  from sagemaker.utils import name_from_base, _tmpdir, resolve_value_from_config, format_tags, Tags
  from sagemaker.s3 import s3_path_join, S3Uploader
  from sagemaker import vpc_utils
  from sagemaker.remote_function.core.stored_function import StoredFunction, _SerializedData
  from sagemaker.remote_function.core.pipeline_variables import Context
  from sagemaker.remote_function.runtime_environment.runtime_environment_manager import RuntimeEnvironmentManager, _DependencySettings
  from sagemaker.remote_function import logging_config
  from sagemaker.remote_function.spark_config import SparkConfig
  from sagemaker.spark import defaults
  from sagemaker.remote_function.custom_file_filter import CustomFileFilter, copy_workdir, resolve_custom_file_filter_from_config_file
label_desc: Use image node_id 9 for calling a global function with example usage: _extend_spark_config_to_request(request_dict, job_settings, s3_base_uri) and returns: extended_request, request_dict