code: def test_explain_feature_union(vec_cls):
      data = [
          {"url": "http://a.com/blog", "text": "security research"},
          {"url": "http://a.com", "text": "security research"},
          {"url": "http://b.com/blog", "text": "health study"},
          {"url": "http://b.com", "text": "health research"},
          {"url": "http://c.com/blog", "text": "security"},
      ]
      ys = [1, 0, 0, 0, 1]
      url_vec = vec_cls(
          preprocessor=lambda x: x["url"],
          analyzer="char",
          ngram_range=(3, 3),
      )
      text_vec = vec_cls(preprocessor=lambda x: x["text"])
      vec = FeatureUnion([("url", url_vec), ("text", text_vec)])
      xs = vec.fit_transform(data)
      clf = LogisticRegression(random_state=42)
      clf.fit(xs, ys)
  
      ivec = invert_hashing_and_fit(vec, data)
      weights_res = explain_weights(clf, ivec)
      html_expl = format_as_html(weights_res)
      write_html(
          clf,
          html_expl,
          "",
          postfix="{}_weights".format(vec_cls.__name__),
      )
      assert "text__security" in html_expl
      assert "url__log" in html_expl
      assert "BIAS" in html_expl
  
      pred_res = explain_prediction(clf, data[0], vec)
      html_expl = format_as_html(pred_res, force_weights=False)
      write_html(clf, html_expl, "", postfix=vec_cls.__name__)
      assert "text: Highlighted in text (sum)" in html_expl
      assert "url: Highlighted in text (sum)" in html_expl
      assert "<b>url:</b> <span" in html_expl
      assert "<b>text:</b> <span" in html_expl
      assert "BIAS" in html_expl
  
imports: from __future__ import absolute_import
  from pprint import pprint
  import attr
  import pytest
  from sklearn.base import BaseEstimator
  from sklearn.feature_extraction import DictVectorizer
  from sklearn.feature_extraction.text import CountVectorizer, HashingVectorizer
  from sklearn.linear_model import LinearRegression
  from sklearn.linear_model import LogisticRegression
  from sklearn.pipeline import FeatureUnion
  from eli5 import explain_prediction, explain_weights
  from eli5.formatters import format_as_html
  from eli5.sklearn import invert_hashing_and_fit, InvertableHashingVectorizer
  from .utils import format_as_all, get_all_features, get_names_coefs, write_html
label_desc: Use image node_id 8 for calling a global function with example usage: test_explain_feature_union(vec_cls) without return types