@lru_cache(maxsize=<NUM_LIT>)<EOL>def _to_span(x, idx=<NUM_LIT:0>):
if isinstance(x, Candidate):<EOL><INDENT>return x[idx].context<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 span.