code: def test_dummy_regressor_sample_weight(
      global_random_seed, n_samples=10
  ):
      random_state = np.random.RandomState(seed=global_random_seed)
  
      X = [[0]] * n_samples
      y = random_state.rand(n_samples)
      sample_weight = random_state.rand(n_samples)
  
      est = DummyRegressor(strategy="mean").fit(X, y, sample_weight)
      assert est.constant_ == np.average(y, weights=sample_weight)
  
      est = DummyRegressor(strategy="median").fit(X, y, sample_weight)
      assert est.constant_ == _weighted_percentile(
          y, sample_weight, 50.0
      )
  
      est = DummyRegressor(strategy="quantile", quantile=0.95).fit(
          X, y, sample_weight
      )
      assert est.constant_ == _weighted_percentile(
          y, sample_weight, 95.0
      )
  
imports: import numpy
  import pytest
  import scipy.sparse
  from sklearn.base import clone
  from sklearn.dummy import DummyClassifier, DummyRegressor
  from sklearn.exceptions import NotFittedError
  from sklearn.utils._testing import assert_almost_equal, assert_array_almost_equal, assert_array_equal, ignore_warnings
  from sklearn.utils.fixes import CSC_CONTAINERS
  from sklearn.utils.stats import _weighted_percentile
label_desc: Use image node_id 37 for calling a global function with example usage: test_dummy_regressor_sample_weight(global_random_seed, n_samples) without return types