code: def _test_k_bin_discretizer_base(self, data):
      data_tensor = torch.from_numpy(data)
  
      for n_bins in [2, 3, 5, 10, 20]:
          for encode in ["ordinal", "onehot", "onehot-dense"]:
              model = KBinsDiscretizer(n_bins=n_bins, encode=encode)
              model.fit(data)
  
              torch_model = hummingbird.ml.convert(model, "torch")
              self.assertIsNotNone(torch_model)
  
              if encode == "onehot":
                  sk_output = model.transform(data).todense()
              else:
                  sk_output = model.transform(data)
  
              np.testing.assert_allclose(
                  sk_output,
                  torch_model.transform(data_tensor),
                  rtol=1e-06,
                  atol=1e-06,
              )
  
file_path: hummingbird/tests/test_sklearn_discretizer_converters.py
imports: import unittest
  import warnings
  import numpy
  import torch
  from sklearn.preprocessing import Binarizer, KBinsDiscretizer
  from sklearn.datasets import load_breast_cancer
  import hummingbird.ml
label_desc: Use image node_id 2 for calling the TestSklearnDiscretizers obj's underlying member method code with example usage: obj._test_k_bin_discretizer_base(data) without return types