code: def stop_orca_context():
      """
      Stop the SparkContext (and stop Ray services across the cluster if necessary) or
      stop the OrcaRayContext.
      """
      from pyspark import SparkContext
      from bigdl.orca.ray import OrcaRayContext
  
      # If users successfully call stop_orca_context after the program finishes,
      # namely when there is no active SparkContext, the registered exit function
      # should do nothing.
      if SparkContext._active_spark_context is not None:
          print("Stopping orca context")
          ray_ctx = OrcaRayContext.get(initialize=False)
          if ray_ctx.initialized:
              ray_ctx.stop()
          else:
              OrcaRayContext._active_ray_context = None
          sc = SparkContext.getOrCreate()
          if sc.getConf().get("spark.master").startswith("spark://"):
              from bigdl.dllib.nncontext import stop_spark_standalone
  
              stop_spark_standalone()
          sc.stop()
      else:
          if OrcaRayContext._active_ray_context is not None:
              print("Stopping ray_orca context")
              ray_ctx = OrcaRayContext.get(initialize=False)
              if ray_ctx.initialized:
                  ray_ctx.stop()
  
imports: import os
  from bigdl.dllib.nncontext import ZooContext
  from bigdl.dllib.utils.log4Error import *
  import pickle
  import hmac
  import hashlib
label_desc: Use image node_id 3 for calling a global function with example usage: stop_orca_context() without return types