code: def spark_session_with_gpu():
      spark_config = {
          "spark.master": f"local-cluster[1, {executor_gpu_amount}, 1024]",
          "spark.python.worker.reuse": "false",
          "spark.driver.host": "127.0.0.1",
          "spark.task.maxFailures": "1",
          "spark.sql.execution.pyspark.udf.simplifiedTraceback.enabled": "false",
          "spark.sql.pyspark.jvmStacktrace.enabled": "true",
          "spark.cores.max": executor_cores,
          "spark.task.cpus": "1",
          "spark.executor.cores": executor_cores,
          "spark.worker.resource.gpu.amount": executor_gpu_amount,
          "spark.task.resource.gpu.amount": "1",
          "spark.executor.resource.gpu.amount": executor_gpu_amount,
          "spark.worker.resource.gpu.discoveryScript": gpu_discovery_script_path,
      }
      builder = SparkSession.builder.appName(
          "xgboost spark python API Tests with GPU"
      )
      for k, v in spark_config.items():
          builder.config(k, v)
      spark = builder.getOrCreate()
      logging.getLogger("pyspark").setLevel(logging.INFO)
      # We run a dummy job so that we block until the workers have connected to the master
      spark.sparkContext.parallelize(
          range(num_workers), num_workers
      ).barrier().mapPartitions(lambda _: []).collect()
      yield spark
      spark.stop()
  
imports: import json
  import logging
  import subprocess
  import numpy
  import pytest
  import sklearn
  from xgboost import testing
  from pyspark.ml.linalg import Vectors
  from pyspark.ml.tuning import CrossValidator, ParamGridBuilder
  from pyspark.sql import SparkSession
  from xgboost.spark import SparkXGBClassifier, SparkXGBRegressor, SparkXGBRegressorModel
label_desc: Use image node_id 2 for calling a global function with example usage: spark_session_with_gpu() without return types