code: def __init__(
      self,
      runtime: str = "spark",
      cores: int = 2,
      num_nodes: int = 1,
      **kwargs,
  ) -> None:
      # Add sys.stdout.fileno for Databricks. In Databricks notebook, sys.stdout is redirected to
      # a ConsoleBuffer object, this object has no attribute fileno, and cause ray init crash.
      # Normally, sys.stdout should have attribute fileno and is set to 1.
      # So set sys.stdout.fileno to 1 when this attribute is missing.
      import sys
  
      if not hasattr(sys.stdout, "fileno"):
          sys.stdout.fileno = lambda: 1  # type: ignore
  
      self.runtime = runtime
      self.initialized = False
  
      if runtime == "spark":
          from bigdl.orca.ray import RayOnSparkContext
  
          self._ray_on_spark_context = RayOnSparkContext(**kwargs)
          self.is_local = self._ray_on_spark_context.is_local
  
      elif runtime == "ray":
          self.is_local = False
          self.ray_args = kwargs.copy()
          self.num_ray_nodes = num_nodes
          self.ray_node_cpu_cores = cores
      else:
          invalidInputError(
              False,
              f"Unsupported runtime: {runtime}. "
              f"Runtime must be spark or ray",
          )
  
      OrcaRayContext._active_ray_context = self
  
file_path: BigDL/python/orca/src/bigdl/orca/ray/raycontext.py
imports: import os
  from threading import Lock
  from bigdl.dllib.utils.log4Error import invalidInputError
  from typing import Optional
label_desc: Use image node_id 1 to create a new OrcaRayContext object from inherited base classes: object with example: obj = OrcaRayContext(runtime, cores, num_nodes)