code: def get_spark_session():
      from pyspark.sql import SparkSession
  
      spark_session = SparkSession.getActiveSession()
      if spark_session is None:
          raise RuntimeError(
              "Spark session haven't been initiated yet. Please use "
              "`SparkSession.builder` to create a spark session and connect to a spark "
              "cluster."
          )
      return spark_session
  
imports: import subprocess
  import os
  import sys
  import random
  import threading
  import collections
  import logging
  import time
label_desc: Use image node_id 7 for calling a global function with example usage: get_spark_session() and returns: spark_session