code: def test_feature_importances_gain():
      from sklearn.datasets import load_digits
  
      digits = load_digits(n_class=2)
      y = digits["target"]
      X = digits["data"]
      xgb_model = xgb.XGBClassifier(
          random_state=0,
          tree_method="exact",
          learning_rate=0.1,
          importance_type="gain",
          base_score=0.5,
      ).fit(X, y)
  
      exp = np.array(
          [
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.00326159,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.00297238,
              0.00988034,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.03512521,
              0.41123885,
              0.0,
              0.0,
              0.0,
              0.0,
              0.01326332,
              0.00160674,
              0.0,
              0.4206952,
              0.0,
              0.0,
              0.0,
              0.0,
              0.00616747,
              0.01237546,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.08240705,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.00100649,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
          ],
          dtype=np.float32,
      )
  
      np.testing.assert_almost_equal(
          xgb_model.feature_importances_, exp
      )
  
      # numeric columns
      import pandas as pd
  
      y = pd.Series(digits["target"])
      X = pd.DataFrame(digits["data"])
      xgb_model = xgb.XGBClassifier(
          random_state=0,
          tree_method="exact",
          learning_rate=0.1,
          importance_type="gain",
          base_score=0.5,
      ).fit(X, y)
      np.testing.assert_almost_equal(
          xgb_model.feature_importances_, exp
      )
  
      xgb_model = xgb.XGBClassifier(
          random_state=0,
          tree_method="exact",
          learning_rate=0.1,
          importance_type="gain",
          base_score=0.5,
      ).fit(X, y)
      np.testing.assert_almost_equal(
          xgb_model.feature_importances_, exp
      )
  
      # no split can be found
      cls = xgb.XGBClassifier(
          min_child_weight=1000, tree_method="hist", n_estimators=1
      )
      cls.fit(X, y)
      assert np.all(cls.feature_importances_ == 0)
  
imports: import json
  import os
  import pickle
  import random
  import tempfile
  import warnings
  from typing import Callable, Optional
  import numpy
  import pytest
  from sklearn.utils.estimator_checks import parametrize_with_checks
  import xgboost
  from xgboost import testing
  from xgboost.testing.ranking import run_ranking_categorical, run_ranking_qid_df
  from xgboost.testing.shared import get_feature_weights, validate_data_initialization
  from xgboost.testing.updater import get_basescore
label_desc: Use image node_id 11 for calling a global function with example usage: test_feature_importances_gain() without return types