code: def test_explain_prediction_clf_multitarget(
      newsgroups_train, filter_missing, use_booster
  ):
      docs, ys, target_names = newsgroups_train
      vec = CountVectorizer(stop_words="english")
      xs = vec.fit_transform(docs)
      if use_booster:
          clf = xgboost.train(
              params={
                  "objective": "multi:softprob",
                  "num_class": len(target_names),
                  "silent": True,
                  "max_depth": 2,
              },
              dtrain=xgboost.DMatrix(xs, label=ys, missing=np.nan),
              num_boost_round=100,
          )
      else:
          clf = XGBClassifier(n_estimators=100, max_depth=2)
          clf.fit(xs, ys)
      feature_filter = (
          (lambda _, v: not np.isnan(v)) if filter_missing else None
      )
      doc = "computer graphics in space: a new religion"
      res = explain_prediction(
          clf,
          doc,
          vec=vec,
          target_names=target_names,
          feature_filter=feature_filter,
      )
      format_as_all(res, clf)
      if not filter_missing:
          check_targets_scores(res)
      graphics_weights = res.targets[1].feature_weights
      assert "computer" in get_all_features(graphics_weights.pos)
      religion_weights = res.targets[3].feature_weights
      assert "religion" in get_all_features(religion_weights.pos)
  
      top_target_res = explain_prediction(
          clf, doc, vec=vec, top_targets=2
      )
      assert len(top_target_res.targets) == 2
      assert (
          sorted(t.proba for t in top_target_res.targets)
          == sorted(t.proba for t in res.targets)[-2:]
      )
  
imports: from __future__ import absolute_import
  import pytest
  import numpy
  import scipy.sparse
  from sklearn.feature_extraction.text import CountVectorizer
  import xgboost
  from xgboost import XGBClassifier, XGBRegressor
  from sklearn.pipeline import FeatureUnion
  from sklearn.preprocessing import FunctionTransformer
  from eli5.xgboost import _parse_tree_dump, _xgb_n_targets, _missing_values_set_to_nan, _parent_value, _parse_dump_line, _check_booster_args
  from eli5.explain import explain_prediction, explain_weights
  from eli5.formatters.text import format_as_text
  from eli5.formatters import fields
  from .utils import format_as_all, get_all_features, check_targets_scores
  from .test_sklearn_explain_weights import test_explain_tree_classifier, test_explain_random_forest_and_tree_feature_filter, test_feature_importances_no_remaining, assert_tree_classifier_explained
  from .test_sklearn_explain_prediction import assert_linear_regression_explained, assert_trained_linear_regression_explained, assert_explain_prediction_single_target, test_explain_clf_binary_iris, test_explain_prediction_pandas
label_desc: Use image node_id 10 for calling a global function with example usage: test_explain_prediction_clf_multitarget(newsgroups_train, filter_missing, use_booster) without return types