code: def test_feature_num_bin(min_data_in_bin):
      X = np.vstack(
          [
              np.random.rand(100),
              np.array([1, 2] * 50),
              np.array([0, 1, 2] * 33 + [0]),
              np.array([1, 2] * 49 + 2 * [np.nan]),
              np.zeros(100),
              np.random.choice([0, 1], 100),
          ]
      ).T
      n_continuous = X.shape[1] - 1
      feature_name = [f"x{i}" for i in range(n_continuous)] + ["cat1"]
      ds_kwargs = {
          "params": {"min_data_in_bin": min_data_in_bin},
          "categorical_feature": [n_continuous],  # last feature
      }
      ds = lgb.Dataset(
          X, feature_name=feature_name, **ds_kwargs
      ).construct()
      expected_num_bins = [
          100 // min_data_in_bin + 1,  # extra bin for zero
          3,  # 0, 1, 2
          3,  # 0, 1, 2
          4,  # 0, 1, 2 + nan
          0,  # unused
          3,  # 0, 1 + nan
      ]
      actual_num_bins = [
          ds.feature_num_bin(i) for i in range(X.shape[1])
      ]
      assert actual_num_bins == expected_num_bins
      # test using defined feature names
      bins_by_name = [ds.feature_num_bin(name) for name in feature_name]
      assert bins_by_name == expected_num_bins
      # test using default feature names
      ds_no_names = lgb.Dataset(X, **ds_kwargs).construct()
      default_names = [f"Column_{i}" for i in range(X.shape[1])]
      bins_by_default_name = [
          ds_no_names.feature_num_bin(name) for name in default_names
      ]
      assert bins_by_default_name == expected_num_bins
      # check for feature indices outside of range
      num_features = X.shape[1]
      with pytest.raises(
          lgb.basic.LightGBMError,
          match=(
              f"Tried to retrieve number of bins for feature index {num_features}, "
              f"but the valid feature indices are \\[0, {num_features - 1}\\]."
          ),
      ):
          ds.feature_num_bin(num_features)
  
imports: import filecmp
  import numbers
  import re
  from copy import deepcopy
  from os import getenv
  from pathlib import Path
  import numpy
  import pytest
  from scipy import sparse
  from sklearn.datasets import dump_svmlight_file, load_svmlight_file
  from sklearn.model_selection import train_test_split
  import lightgbm
  from lightgbm.compat import PANDAS_INSTALLED, pd_DataFrame, pd_Series
  from .utils import dummy_obj, load_breast_cancer, mse_obj, np_assert_array_equal
label_desc: Use image node_id 31 for calling a global function with example usage: test_feature_num_bin(min_data_in_bin) without return types