code: def test_valid_n_bins():
      KBinsDiscretizer(n_bins=2).fit_transform(X)
      KBinsDiscretizer(n_bins=np.array([2])[0]).fit_transform(X)
      assert KBinsDiscretizer(n_bins=2).fit(
          X
      ).n_bins_.dtype == np.dtype(int)
  
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 2 for calling a global function with example usage: test_valid_n_bins() without return types