def METHOD_NAME(self) -> SparkSession:
    """Instantiate a new SparkSession or return the existing one."""
    is_training_job = self.environment_helper.is_training_job()
    instance_count = self.environment_helper.get_instance_count()
    spark_configs = self._get_spark_configs(is_training_job)
    spark_conf = SparkConf().setAll(spark_configs).setAppName(SPARK_APP_NAME)
    if instance_count == 1:
        spark_conf.setMaster("local[*]")
    sc = SparkContext.getOrCreate(conf=spark_conf)
    jsc = sc._jsc  # Java Spark Context (JVM SparkContext)
    for cfg in self._get_jsc_hadoop_configs():
        jsc.hadoopConfiguration().set(cfg[0], cfg[1])
    return SparkSession(sparkContext=sc)