code: def init_spark_on_k8s_cluster(
      self,
      master,
      container_image,
      num_executors,
      executor_cores,
      executor_memory="2g",
      driver_memory="1g",
      driver_cores=4,
      extra_executor_memory_for_ray=None,
      extra_python_lib=None,
      penv_archive=None,
      conf=None,
      jars=None,
      python_location=None,
  ):
      import subprocess
  
      print("Initializing SparkContext for k8s-cluster mode")
      executor_python_env = "python_env"
  
      invalidInputError(
          penv_archive,
          "You should specify penv_archive explicitly for k8s cluster mode",
      )
  
      archive = "{}#{}".format(penv_archive, executor_python_env)
  
      submit_args = "--master " + master + " --deploy-mode cluster"
      submit_args = submit_args + " --archives {}".format(archive)
      submit_args = submit_args + gen_submit_args(
          driver_cores,
          driver_memory,
          num_executors,
          executor_cores,
          executor_memory,
          extra_python_lib,
          jars,
      )
  
      conf = enrich_conf_for_spark(
          conf,
          driver_cores,
          driver_memory,
          num_executors,
          executor_cores,
          executor_memory,
          extra_executor_memory_for_ray,
      )
  
      conf["spark.pyspark.driver.python"] = "{}/bin/python".format(
          executor_python_env
      )
      conf["spark.pyspark.python"] = "{}/bin/python".format(
          executor_python_env
      )
      conf["spark.kubernetes.driverEnv.onDriver"] = "True"
  
      py_version = ".".join(platform.python_version().split(".")[0:2])
      preload_so = (
          executor_python_env + "/lib/libpython" + py_version + "m.so"
      )
      ld_path = (
          executor_python_env
          + "/lib:"
          + executor_python_env
          + "/lib/python"
          + py_version
          + "/lib-dynload"
      )
      if "spark.executor.extraLibraryPath" in conf:
          ld_path = "{}:{}".format(
              ld_path, conf["spark.executor.extraLibraryPath"]
          )
      conf.update(
          {
              "spark.cores.max": num_executors * executor_cores,
              "spark.executorEnv.PYTHONHOME": executor_python_env,
              "spark.executor.extraLibraryPath": ld_path,
              "spark.executorEnv.LD_PRELOAD": preload_so,
              "spark.kubernetes.container.image": container_image,
          }
      )
      if "spark.executor.extraClassPath" not in conf:
          # BigDL Class path in k8s image
          bigdl_class_version = get_bigdl_class_version()
          conf["spark.executor.extraClassPath"] = (
              "/opt/" + "bigdl-" + bigdl_class_version + "/jars/*"
          )
      conf["spark.driver.extraClassPath"] = conf[
          "spark.executor.extraClassPath"
      ]
      sys_args = "local://" + " ".join(sys.argv)
      conf = " --conf " + " --conf ".join(
          "{}={}".format(*i) for i in conf.items()
      )
      submit_command = (
          "spark-submit " + submit_args + " " + conf + " " + sys_args
      )
      print(submit_command)
      submit_command_list = submit_command.split()
      return_value = subprocess.run(submit_command_list)
      return return_value
  
imports: import os
  import sys
  import random
  import platform
  from pyspark import SparkContext
  from bigdl.dllib.nncontext import init_internal_nncontext, init_spark_conf
  from bigdl.dllib.utils.utils import detect_python_location, pack_penv, get_node_ip
  from bigdl.dllib.utils.utils import get_executor_conda_zoo_classpath
  from bigdl.dllib.utils.utils import get_zoo_bigdl_classpath_on_driver
  from bigdl.dllib.utils.utils import get_bigdl_class_version
  from bigdl.dllib.utils.utils import get_bigdl_image_workdir
  from bigdl.dllib.utils.utils import is_valid_ip_address
  from bigdl.dllib.utils.engine import get_bigdl_jars
  from bigdl.dllib.utils.log4Error import *
label_desc: Use image node_id 9 for calling the SparkRunner obj's underlying member method code with example usage: obj.init_spark_on_k8s_cluster(master, container_image, num_executors, executor_cores, executor_memory, driver_memory, driver_cores, extra_executor_memory_for_ray, extra_python_lib, penv_archive, conf, jars, python_location) and returns: return_value