code: def _fit_estimator(estimator, X, y, sample_weight=None):
      estimator = clone(estimator)
      if sample_weight is not None:
          estimator.fit(X, y, sample_weight=sample_weight)
      else:
          estimator.fit(X, y)
      return estimator
  
imports: import numpy
  from abc import ABCMeta
  from .base import BaseEstimator, clone
  from .base import RegressorMixin, ClassifierMixin
  from .utils import check_array, check_X_y
  from .utils.fixes import parallel_helper
  from .utils.validation import check_is_fitted, has_fit_parameter
  from .externals.joblib import Parallel, delayed
  from .externals import six
label_desc: Use image node_id 1 for calling a global function with example usage: _fit_estimator(estimator, X, y, sample_weight) and returns: estimator