code: def init_internal_nncontext(
      conf=None, spark_log_level="WARN", redirect_spark_log=True
  ):
      """
      Creates or gets a SparkContext with optimized configurations for BigDL performance.
      This method will also initialize the BigDL engine.
  
      Note: If you use spark-shell or Jupyter notebook, as the SparkContext is created
      before your code, you have to set the Spark configurations through command line options
      or the properties file before calling this method. In this case, you are recommended
      to use the launch scripts we provide:
      https://github.com/intel-analytics/BigDL/tree/main/scripts.
  
      :param conf: An instance of SparkConf. If not specified, a new SparkConf with
             BigDL configurations would be created and used.
             You can also input a string here to indicate the name of the application.
      :param spark_log_level: The log level for Spark. Default to be 'WARN'.
      :param redirect_spark_log: Whether to redirect the Spark log to local file. Default to be True.
  
      :return: An instance of SparkContext.
      """
      has_activate_sc = SparkContext._active_spark_context is not None
  
      if isinstance(conf, six.string_types):
          sc = getOrCreateSparkContext(conf=None, appName=conf)
      else:
          sc = getOrCreateSparkContext(conf=conf)
      sc.setLogLevel(spark_log_level)
  
      if ZooContext.log_output:
          import uuid
  
          uuidStr = str(uuid.uuid4())
          log_path = "bigdl" + uuidStr + ".log"
          abs_path = "/tmp/" + log_path
          logger.info(f"log path {abs_path}")
          stderr_reader = threading.Thread(
              target=_read_stream,
              daemon=True,
              kwargs=dict(fd=open(abs_path, "w+"), fn=sys.stdout.write),
          )
          stderr_reader.start()
          sc.setSystemProperty("logFilename", log_path)
  
      check_version()
      if redirect_spark_log:
          redire_spark_logs()
          show_bigdl_info_logs()
      init_engine()
      set_python_home()
      return sc
  
imports: from bigdl.dllib.utils.common import *
  from bigdl.dllib.utils.file_utils import callZooFunc
  from bigdl.dllib.utils.utils import set_python_home
  from bigdl.dllib.utils.log4Error import *
  import warnings
  import multiprocessing
  import os
  import threading
  import sys
label_desc: Use image node_id 10 for calling a global function with example usage: init_internal_nncontext(conf, spark_log_level, redirect_spark_log) and returns: sc