code: def test_text_explainer_char_based(token_pattern):
      text = "Hello, world!"
      predict_proba = substring_presence_predict_proba("lo")
  
      te = TextExplainer(char_based=True, token_pattern=token_pattern)
      te.fit(text, predict_proba)
      print(te.metrics_)
      assert te.metrics_["score"] > 0.95
      assert te.metrics_["mean_KL_divergence"] < 0.1
  
      res = te.explain_prediction()
      format_as_all(res, te.clf_)
      check_targets_scores(res)
      assert res.targets[0].feature_weights.pos[0].feature == "lo"
  
      # another way to look at results (not that useful for char ngrams)
      res = te.explain_weights()
      assert res.targets[0].feature_weights.pos[0].feature == "lo"
  
file_path: eli5/tests/test_lime.py
imports: from __future__ import absolute_import
  import numpy
  from sklearn.feature_extraction.text import HashingVectorizer, CountVectorizer
  from sklearn.naive_bayes import MultinomialNB
  from sklearn.tree import DecisionTreeClassifier
  from sklearn.pipeline import make_pipeline
  import pytest
  from eli5.lime import TextExplainer
  from eli5.formatters import format_as_text
  from .utils import format_as_all, check_targets_scores
label_desc: Use image node_id 3 for calling a global function with example usage: test_text_explainer_char_based(token_pattern) without return types