code: def _targets_lines(
      explanation,  # type: Explanation
      hl_spaces,  # type: Optional[bool]
      show_feature_values,  # type: bool
      explaining_prediction,  # type: bool
  ):
      # type: (...) -> List[str]
      lines = []
      assert explanation.targets is not None
      for target in explanation.targets:
          scores = _format_scores(target.proba, target.score)
          if scores:
              scores = " (%s)" % scores
  
          header = "%s%r%s top features" % (
              "y=" if not explanation.is_regression else "",
              target.target,
              scores,
          )
          lines.append(header)
  
          if explaining_prediction:
              table_header = ["Contribution", "Feature"]
          else:
              table_header = ["Weight", "Feature"]
          if show_feature_values:
              table_header.append("Value")
              table_line = lambda fw: [
                  format_weight(fw.weight),
                  _format_feature(fw.feature, hl_spaces),
                  format_value(fw.value),
              ]
              col_align = "rlr"
          else:
              table_line = lambda fw: [
                  format_weight(fw.weight),
                  _format_feature(fw.feature, hl_spaces),
              ]
              col_align = "rl"
  
          w = target.feature_weights
          assert w is not None
          table = eli5_tabulate(
              [table_line(fw) for fw in chain(w.pos, reversed(w.neg))],
              header=table_header,
              col_align=col_align,
          )
          max_width = len(table[1])
          pos_table = "\n".join(table[: -len(w.neg)])
          neg_table = "\n".join(table[-len(w.neg) :])
  
          if pos_table:
              lines.append(pos_table)
          if w.pos_remaining:
              lines.append(
                  _format_remaining(
                      w.pos_remaining, "positive", max_width
                  )
              )
          if w.neg_remaining:
              lines.append(
                  _format_remaining(
                      w.neg_remaining, "negative", max_width
                  )
              )
          if neg_table:
              lines.append(neg_table)
  
          lines.append("")
      return lines
  
imports: from __future__ import absolute_import
  from itertools import chain
  import six
  from tabulate import tabulate
  from typing import List, Optional, Iterator
  from eli5.base import Explanation, FeatureImportances
  from .None import fields
  from .features import FormattedFeatureName
  from .utils import format_signed, format_value, format_weight, has_any_values_for_weights, replace_spaces, should_highlight_spaces
  from .utils import tabulate
  from .trees import tree2text
label_desc: Use image node_id 9 for calling a global function with example usage: _targets_lines(explanation, hl_spaces, show_feature_values, explaining_prediction) and returns: lines