class_docstr: Maps feature ids to words or word-positions
docstr: Adds text with highlighted words to visualization.
  
  Args:
       exp: list of tuples [(id, weight), (id,weight)]
       label: label id (integer)
       div_name: name of div object to be used for rendering(in js)
       exp_object_name: name of js explanation object
       text: if False, return empty
       opacity: if True, fade colors according to weight
code: def visualize_instance_html(
      self,
      exp,
      label,
      div_name,
      exp_object_name,
      text=True,
      opacity=True,
  ):
      """Adds text with highlighted words to visualization.
  
      Args:
           exp: list of tuples [(id, weight), (id,weight)]
           label: label id (integer)
           div_name: name of div object to be used for rendering(in js)
           exp_object_name: name of js explanation object
           text: if False, return empty
           opacity: if True, fade colors according to weight
      """
      if not text:
          return ""
      text = (
          self.indexed_string.raw_string()
          .encode("utf-8", "xmlcharrefreplace")
          .decode("utf-8")
      )
      text = re.sub(r"[<>&]", "|", text)
      exp = [
          (
              self.indexed_string.word(x[0]),
              self.indexed_string.string_position(x[0]),
              x[1],
          )
          for x in exp
      ]
      all_occurrences = list(
          itertools.chain.from_iterable(
              [itertools.product([x[0]], x[1], [x[2]]) for x in exp]
          )
      )
      all_occurrences = [
          (x[0], int(x[1]), x[2]) for x in all_occurrences
      ]
      ret = """
              %s.show_raw_text(%s, %d, %s, %s, %s);
              """ % (
          exp_object_name,
          json.dumps(all_occurrences),
          label,
          json.dumps(text),
          div_name,
          json.dumps(opacity),
      )
      return ret
  
imports: from functools import partial
  import itertools
  import json
  import re
  import numpy
  import scipy
  import sklearn
  from sklearn.utils import check_random_state
  from .None import explanation
  from .None import lime_base
label_desc: Use image node_id 3 for calling the TextDomainMapper obj's underlying member method code with example usage: obj.visualize_instance_html(exp, label, div_name, exp_object_name, text, opacity) and returns: ret, str