code: def test_render_weighted_spans_word():
      weighted_spans = DocWeightedSpans(
          document="i see: a leaning lemon tree",
          spans=[
              ("see", [(2, 5)], 0.2),
              ("tree", [(23, 27)], -0.6),
              ("leaning lemon", [(9, 16), (17, 22)], 0.5),
              ("lemon tree", [(17, 22), (23, 27)], 0.8),
          ],
          preserve_density=False,
      )
      s = _render_weighted_spans(weighted_spans)
      print(s)
      assert s.startswith(
          '<span style="opacity: 0.80">i </span>'
          "<span"
          ' style="background-color: hsl(120, 100.00%, 89.21%); opacity: 0.83"'
          ' title="0.200">see</span>'
      )
      s_without_styles = re.sub('style=".*?"', "", s)
      assert s_without_styles == (
          "<span >i </span>"
          '<span  title="0.200">see</span>'
          "<span >: a </span>"
          '<span  title="0.500">leaning</span>'
          "<span > </span>"
          '<span  title="1.300">lemon</span>'
          "<span > </span>"
          '<span  title="0.200">tree</span>'
      )
  
imports: import re
  import pytest
  import numpy
  from sklearn.datasets import make_regression
  from sklearn.linear_model import LinearRegression
  from eli5.base import DocWeightedSpans, FeatureWeight
  from eli5 import explain_weights_sklearn, explain_prediction_sklearn
  from eli5.formatters import format_as_text, format_as_html, format_html_styles, FormattedFeatureName
  from eli5.formatters.html import _format_unhashed_feature, render_weighted_spans, _format_single_feature, _format_feature, remaining_weight_color_hsl, weight_color_hsl
  from eli5.formatters.text_helpers import get_char_weights, PreparedWeightedSpans
  from .utils import write_html
label_desc: Use image node_id 9 for calling a global function with example usage: test_render_weighted_spans_word() without return types