class_docstr: Utility class to help create wrapper classes from Java/Scala
  implementations of pipeline components.
class_docstr_tok: ["Utility","class","to","help","create","wrapper","classes","from","Java\/Scala","implementations","of","pipeline","components","."]
docstr: 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.
docstr_tok: ["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","."]
code: def _from_java(java_stage: "JavaObject") -> "JP":  # type: ignore
      """
      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.
      """
  
      def __get_class(clazz: str) -> Type[JP]:
          """
          Loads Python class from its name.
          """
          parts = clazz.split(".")
          module = ".".join(parts[:-1])
          m = __import__(module, fromlist=[parts[-1]])
          return getattr(m, parts[-1])
  
      stage_name = (
          java_stage.getClass()
          .getName()
          .replace("org.apache.spark", "pyspark")
      )
      # 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
  
          # SPARK-10931: Temporary fix so that persisted models would own params from Estimator
          if issubclass(py_type, JavaModel):
              py_stage._create_params_from_java()
  
          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
  
imports: from abc import ABCMeta, abstractmethod
  from typing import Any, Generic, Optional, List, Type, TypeVar, TYPE_CHECKING
  from pyspark import since
  from pyspark import SparkContext
  from pyspark.sql import DataFrame
  from pyspark.ml import Estimator, Predictor, PredictionModel, Transformer, Model
  from pyspark.ml.base import _PredictorParams
  from pyspark.ml.param import Param, Params
  from pyspark.ml.util import _jvm
  from pyspark.ml.common import inherit_doc, _java2py, _py2java
label_desc: Use image node_id 9 for calling the JavaParams obj's underlying member method code with example usage: obj._from_java(java_stage) and returns: py_stage, getattr