<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_weighted_spans(doc, vec, vectorized, target_expl):
 # type: (Any, Any, bool, TargetExplanation) -> None """ Compute and set ``target_expl.weighted_spans`` attribute, when possible. """

    if vec is None or vectorized:
        return

    weighted_spans = get_weighted_spans(doc, vec, target_expl.feature_weights)
    if weighted_spans:
        target_expl.weighted_spans = weighted_spans