code: def from_java(java_stage, stage_name):
      """
      Given a Java object, create and return a Python wrapper of it.
      Used for ML persistence.
      Meta-algorithms such as Pipeline should override this method as a classmethod.
  
      Args:
          java_stage (str):
          stage_name (str):
  
      Returns:
          object: The python wrapper
      """
  
      def __get_class(clazz):
          """
          Loads a python object from its class
  
          Args:
              clazz (str): The name of the class
  
          Returns:
              object: The python object
          """
          parts = clazz.split(".")
          module = ".".join(parts[:-1])
          m = __import__(module)
          for comp in parts[1:]:
              m = getattr(m, comp)
          return m
  
      # Generate a default new instance from the stage_name class.
      py_type = __get_class(stage_name)
      if issubclass(py_type, JavaParams):
          # Load information from java_stage to the instance.
          py_stage = py_type()
          py_stage._java_obj = java_stage
          py_stage._resetUid(java_stage.uid())
          py_stage._transfer_params_from_java()
      elif hasattr(py_type, "_from_java"):
          py_stage = py_type._from_java(java_stage)
      else:
          raise NotImplementedError(
              "This Java stage cannot be loaded into Python currently: %r"
              % stage_name,
          )
      return py_stage
  
file_path: SynapseML/core/src/main/python/synapse/ml/core/schema/Utils.py
imports: import sys
  from pyspark.ml.util import JavaMLReadable, JavaMLReader, MLReadable
  from pyspark.ml.wrapper import JavaParams
  from pyspark.ml.common import inherit_doc, _java2py
  from pyspark import SparkContext
label_desc: Use image node_id 1 for calling a global function with example usage: from_java(java_stage, stage_name) and returns: py_stage, m