code: def test_log_explanation_with_small_features():
      """
      Verifies that `log_explanation` does not fail even when `features` has less records than
      `_MAXIMUM_BACKGROUND_DATA_SIZE`.
      """
      num_rows = 50
      assert num_rows < mlflow.shap._MAXIMUM_BACKGROUND_DATA_SIZE
  
      X, y = get_diabetes()
      X, y = X.iloc[:num_rows], y[:num_rows]
      model = RandomForestRegressor()
      model.fit(X, y)
  
      with mlflow.start_run() as run:
          explanation_uri = mlflow.shap.log_explanation(
              model.predict, X
          )
  
      artifact_path = "model_explanations_shap"
      artifacts = set(yield_artifacts(run.info.run_id))
  
      assert explanation_uri == os.path.join(
          run.info.artifact_uri, artifact_path
      )
      assert artifacts == {
          os.path.join(artifact_path, "base_values.npy"),
          os.path.join(artifact_path, "shap_values.npy"),
          os.path.join(artifact_path, "summary_bar_plot.png"),
      }
  
      explainer = shap.KernelExplainer(
          model.predict, shap.kmeans(X, num_rows)
      )
      shap_values_expected = explainer.shap_values(X)
  
      base_values = np.load(
          os.path.join(explanation_uri, "base_values.npy")
      )
      shap_values = np.load(
          os.path.join(explanation_uri, "shap_values.npy")
      )
      np.testing.assert_array_equal(
          base_values, explainer.expected_value
      )
      np.testing.assert_array_equal(shap_values, shap_values_expected)
  
imports: import os
  from collections import namedtuple
  import matplotlib.pyplot
  import numpy
  import pandas
  import pytest
  import shap
  from sklearn.datasets import load_diabetes, load_iris
  from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor
  import mlflow
  from mlflow import MlflowClient
label_desc: Use image node_id 13 for calling a global function with example usage: test_log_explanation_with_small_features() without return types