code: def init_orca(cluster_mode, extra_python_lib=None):
      if cluster_mode == "local":
          sc = init_orca_context(cluster_mode="local")
      elif cluster_mode.startswith("yarn"):
          if cluster_mode == "yarn-client":
              sc = init_orca_context(
                  cluster_mode="yarn-client",
                  cores=4,
                  memory="10g",
                  num_nodes=2,
                  extra_python_lib=extra_python_lib,
              )
          elif cluster_mode == "yarn-cluster":
              sc = init_orca_context(
                  cluster_mode="yarn-cluster",
                  cores=4,
                  memory="10g",
                  num_nodes=2,
                  extra_python_lib=extra_python_lib,
              )
      elif cluster_mode.startswith("k8s"):
          if cluster_mode == "k8s-client":
              conf = {
                  "spark.kubernetes.executor.volumes.persistentVolumeClaim.nfsvolumeclaim"
                  ".options.claimName": "nfsvolumeclaim",
                  "spark.kubernetes.executor.volumes.persistentVolumeClaim.nfsvolumeclaim"
                  ".mount.path": "/bigdl/nfsdata",
              }
              sc = init_orca_context(
                  cluster_mode="k8s-client",
                  cores=4,
                  memory="10g",
                  num_nodes=2,
                  extra_python_lib=extra_python_lib,
                  master=os.environ.get("RUNTIME_SPARK_MASTER"),
                  container_image=os.environ.get(
                      "RUNTIME_K8S_SPARK_IMAGE"
                  ),
                  conf=conf,
              )
          elif cluster_mode == "k8s-cluster":
              conf = {
                  "spark.kubernetes.driver.volumes.persistentVolumeClaim.nfsvolumeclaim"
                  ".options.claimName": "nfsvolumeclaim",
                  "spark.kubernetes.driver.volumes.persistentVolumeClaim.nfsvolumeclaim"
                  ".mount.path": "/bigdl/nfsdata",
                  "spark.kubernetes.executor.volumes.persistentVolumeClaim.nfsvolumeclaim"
                  ".options.claimName": "nfsvolumeclaim",
                  "spark.kubernetes.executor.volumes.persistentVolumeClaim.nfsvolumeclaim"
                  ".mount.path": "/bigdl/nfsdata",
                  "spark.kubernetes.authenticate.driver.serviceAccountName": "spark",
                  "spark.kubernetes.file.upload.path": "/bigdl/nfsdata/",
              }
              sc = init_orca_context(
                  cluster_mode="k8s-cluster",
                  cores=4,
                  memory="10g",
                  num_nodes=2,
                  extra_python_lib=extra_python_lib,
                  master=os.environ.get("RUNTIME_SPARK_MASTER"),
                  container_image=os.environ.get(
                      "RUNTIME_K8S_SPARK_IMAGE"
                  ),
                  penv_archive="file:///bigdl/nfsdata/environment.tar.gz",
                  conf=conf,
              )
      elif cluster_mode == "bigdl-submit":
          sc = init_orca_context(cluster_mode="bigdl-submit")
      elif cluster_mode == "spark-submit":
          sc = init_orca_context(cluster_mode="spark-submit")
      else:
          exit(
              "cluster_mode should be one of 'local', 'yarn-client', "
              "'yarn-cluster', 'k8s-client', 'k8s-cluster', 'bigdl-submit' or 'spark-submit', "
              "but got " + cluster_mode
          )
      return sc
  
file_path: BigDL/python/orca/tutorial/NCF/utils.py
imports: import os
  import argparse
  import json
  import tempfile
  from bigdl.dllib.utils.file_utils import is_local_path
  from bigdl.orca.data.file import put_local_file_to_remote, get_remote_file_to_local
  from bigdl.orca import init_orca_context, stop_orca_context, OrcaContext
label_desc: Use image node_id 2 for calling a global function with example usage: init_orca(cluster_mode, extra_python_lib) and returns: sc