code: def score_with_sample_weight(
      estimator, X, y=None, sample_weight=None
  ):
      if sklearn_version() < "0.19":
          if (
              isinstance(estimator, Pipeline)
              and sample_weight is not None
          ):
              estimator = _PipelinePatched(estimator.steps)
      if sample_weight is None:
          return estimator.score(X, y)
      return estimator.score(X, y, sample_weight=sample_weight)
  
imports: from __future__ import absolute_import
  from typing import List, Any
  import numpy
  from scipy.stats import entropy
  from sklearn.pipeline import Pipeline
  from sklearn.utils import check_random_state, issparse
  from sklearn.utils.metaestimators import if_delegate_has_method
  from sklearn.utils import shuffle
  from eli5.utils import vstack
  from eli5.sklearn.utils import sklearn_version
label_desc: Use image node_id 4 for calling a global function with example usage: score_with_sample_weight(estimator, X, y, sample_weight) and returns: estimator, estimator