@lru_cache(maxsize=<NUM_LIT>)<EOL>def _to_spans(x):
if isinstance(x, Candidate):<EOL><INDENT>return [_to_span(m) for m in x]<EOL><DEDENT>elif isinstance(x, Mention):<EOL><INDENT>return [x.context]<EOL><DEDENT>elif isinstance(x, TemporarySpanMention):<EOL><INDENT>return [x]<EOL><DEDENT>else:<EOL><INDENT>raise ValueError(f"<STR_LIT>")<EOL><DEDENT>
Convert a Candidate, Mention, or Span to a list of spans.