class_docstr: Abstract class for estimators that fit models to data.
  
  .. versionadded:: 1.3.0
docstr: Fits a model to the input dataset with optional parameters.
  
  .. versionadded:: 1.3.0
  
  Parameters
  ----------
  dataset : :py:class:`pyspark.sql.DataFrame`
      input dataset.
  params : dict or list or tuple, optional
      an optional param map that overrides embedded params. If a list/tuple of
      param maps is given, this calls fit on each param map and returns a list of
      models.
  
  Returns
  -------
  :py:class:`Transformer` or a list of :py:class:`Transformer`
      fitted model(s)
docstr_tok: ["Fits","a","model","to","the","input","dataset","with","optional","parameters",".","..","versionadded",":",":","1.3.0","Parameters","--","--","--","--","--","dataset",":",":","py",":","class",":","`","pyspark.sql.DataFrame","`","input","dataset",".","params",":","dict","or","list","or","tuple",",","optional","an","optional","param","map","that","overrides","embedded","params",".","If","a","list\/tuple","of","param","maps","is","given",",","this","calls","fit","on","each","param","map","and","returns","a","list","of","models",".","Returns","--","--","--","-",":","py",":","class",":","`","Transformer","`","or","a","list","of",":","py",":","class",":","`","Transformer","`","fitted","model","(","s",")"]
code: def fit(
      self,
      dataset: DataFrame,
      params: Optional[
          Union["ParamMap", List["ParamMap"], Tuple["ParamMap"]]
      ] = None,
  ) -> Union[M, List[M]]:
      """
      Fits a model to the input dataset with optional parameters.
  
      .. versionadded:: 1.3.0
  
      Parameters
      ----------
      dataset : :py:class:`pyspark.sql.DataFrame`
          input dataset.
      params : dict or list or tuple, optional
          an optional param map that overrides embedded params. If a list/tuple of
          param maps is given, this calls fit on each param map and returns a list of
          models.
  
      Returns
      -------
      :py:class:`Transformer` or a list of :py:class:`Transformer`
          fitted model(s)
      """
      if params is None:
          params = dict()
      if isinstance(params, (list, tuple)):
          models: List[Optional[M]] = [None] * len(params)
          for index, model in self.fitMultiple(dataset, params):
              models[index] = model
          return cast(List[M], models)
      elif isinstance(params, dict):
          if params:
              return self.copy(params)._fit(dataset)
          else:
              return self._fit(dataset)
      else:
          raise TypeError(
              "Params must be either a param map or a list/tuple of param maps, "
              "but got %s." % type(params)
          )
  
imports: from abc import ABCMeta, abstractmethod
  import copy
  import threading
  from typing import Any, Callable, Generic, Iterator, List, Optional, Sequence, Tuple, TypeVar, Union, cast, overload, TYPE_CHECKING
  from pyspark import since
  from pyspark.ml.param import P
  from pyspark.ml.common import inherit_doc
  from pyspark.ml.param.shared import HasInputCol, HasOutputCol, HasLabelCol, HasFeaturesCol, HasPredictionCol, Params
  from pyspark.sql.dataframe import DataFrame
  from pyspark.sql.functions import udf
  from pyspark.sql.types import DataType, StructField, StructType
label_desc: Use image node_id 5 for calling the Estimator obj's underlying member method code with example usage: obj.fit(dataset, params) and returns: cast, self, self