code: def test_kbinsdiscretizer_no_mutating_sample_weight(strategy):
      """Make sure that `sample_weight` is not changed in place."""
      est = KBinsDiscretizer(
          n_bins=3, encode="ordinal", strategy=strategy
      )
      sample_weight = np.array([1, 3, 1, 2], dtype=np.float64)
      sample_weight_copy = np.copy(sample_weight)
      est.fit(X, sample_weight=sample_weight)
      assert_allclose(sample_weight, sample_weight_copy)
  
imports: import warnings
  import numpy
  import pytest
  import scipy.sparse
  from sklearn import clone
  from sklearn.preprocessing import KBinsDiscretizer, OneHotEncoder
  from sklearn.utils._testing import assert_allclose, assert_allclose_dense_sparse, assert_array_almost_equal, assert_array_equal
label_desc: Use image node_id 7 for calling a global function with example usage: test_kbinsdiscretizer_no_mutating_sample_weight(strategy) without return types