code: def render_targets_weighted_spans(
      targets,  # type: List[TargetExplanation]
      preserve_density,  # type: Optional[bool]
  ):
      # type: (...) -> List[Optional[str]]
      """Return a list of rendered weighted spans for targets.
      Function must accept a list in order to select consistent weight
      ranges across all targets.
      """
      prepared_weighted_spans = prepare_weighted_spans(
          targets, preserve_density
      )
  
      def _fmt_pws(pws):
          # type: (PreparedWeightedSpans) -> str
          name = (
              "<b>{}:</b> ".format(pws.doc_weighted_spans.vec_name)
              if pws.doc_weighted_spans.vec_name
              else ""
          )
          return "{}{}".format(name, render_weighted_spans(pws))
  
      def _fmt_pws_list(pws_lst):
          # type: (List[PreparedWeightedSpans]) -> str
          return "<br/>".join(_fmt_pws(pws) for pws in pws_lst)
  
      return [
          _fmt_pws_list(pws_lst) if pws_lst else None
          for pws_lst in prepared_weighted_spans
      ]
  
imports: from __future__ import absolute_import
  from itertools import groupby
  from typing import List, Optional, Tuple
  import numpy
  from jinja2 import Environment, PackageLoader
  from eli5 import _graphviz
  from eli5.base import Explanation, TargetExplanation, FeatureWeights, FeatureWeight
  from eli5.utils import max_or_0
  from .utils import format_signed, format_value, format_weight, has_any_values_for_weights, replace_spaces, should_highlight_spaces
  from .None import fields
  from .features import FormattedFeatureName
  from .trees import tree2text
  from .text_helpers import prepare_weighted_spans, PreparedWeightedSpans
label_desc: Use image node_id 3 for calling a global function with example usage: render_targets_weighted_spans(targets, preserve_density) and returns: unknown, str, str