code: def test_lightgbm_classifier_with_categorical(n_classes):
      n_samples = 100
      n_features = 8
      n_categorical = 8
      X, y = make_classification_with_categorical(
          n_samples=n_samples,
          n_features=n_features,
          n_categorical=n_categorical,
          n_informative=n_features,
          n_redundant=0,
          n_repeated=0,
          n_classes=n_classes,
          random_state=2022,
      )
  
      dtrain = lgb.Dataset(
          X, label=y, categorical_feature=range(n_categorical)
      )
      params = {"num_leaves": 64, "seed": 0, "min_data_per_group": 1}
      if n_classes == 2:
          params["objective"] = "binary"
          params["metric"] = "binary_logloss"
      else:
          params["objective"] = "multiclass"
          params["metric"] = "multi_logloss"
          params["num_class"] = n_classes
      lgb_model = lgb.train(
          params,
          dtrain,
          num_boost_round=10,
          valid_sets=[dtrain],
          valid_names=["train"],
      )
      assert (
          count_categorical_split(
              treelite.Model.from_lightgbm(lgb_model)
          )
          > 0
      )
  
      # Insert NaN randomly into X
      X_test = X.values.copy()
      n_nan = int(np.floor(X.size * 0.1))
      rng = np.random.default_rng(seed=0)
      index_nan = rng.choice(X.size, size=n_nan, replace=False)
      X_test.ravel()[index_nan] = np.nan
  
      explainer = TreeExplainer(model=lgb_model)
      out = explainer.shap_values(X_test)
  
      ref_explainer = shap.explainers.Tree(model=lgb_model)
      ref_out = np.array(ref_explainer.shap_values(X_test))
      if n_classes == 2:
          ref_out = ref_out[1, :, :]
          ref_expected_value = ref_explainer.expected_value[1]
      else:
          ref_expected_value = ref_explainer.expected_value
      np.testing.assert_almost_equal(out, ref_out, decimal=5)
      np.testing.assert_almost_equal(
          explainer.expected_value, ref_expected_value, decimal=5
      )
  
imports: from cuml.testing.utils import as_type
  import cuml
  from cuml.ensemble import RandomForestClassifier
  from cuml.ensemble import RandomForestRegressor
  from cuml.common.exceptions import NotFittedError
  from cuml.internals.import_utils import has_sklearn
  from cuml.internals.import_utils import has_lightgbm, has_shap
  from cuml.explainer.tree_shap import TreeExplainer
  from hypothesis import given, settings, assume, HealthCheck, strategies
  from cuml.internals.safe_imports import gpu_only_import
  import json
  import pytest
  import treelite
  from cuml.internals.safe_imports import cpu_only_import
label_desc: Use image node_id 16 for calling a global function with example usage: test_lightgbm_classifier_with_categorical(n_classes) without return types