docs: def get_weighted_spans(doc, vec, feature_weights):
      # type: (Any, Any, FeatureWeights) -> Optional[WeightedSpans]
      """ If possible, return a dict with preprocessed document and a list
      of spans with weights, corresponding to features in the document.
      """
      if isinstance(vec, FeatureUnion):
          return _get_weighted_spans_from_union(doc, vec, feature_weights)
      else:
          result = _get_doc_weighted_spans(doc, vec, feature_weights)
          if result is not None:
              found_features, doc_weighted_spans = result
              return WeightedSpans(
                  [doc_weighted_spans],
                  other=_get_other(feature_weights, [('', found_features)]),
              )
      return None