<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _to_span(x, idx=0):
 """Convert a Candidate, Mention, or Span to a span."""

    if isinstance(x, Candidate):
        return x[idx].context
    elif isinstance(x, Mention):
        return x.context
    elif isinstance(x, TemporarySpanMention):
        return x
    else:
        raise ValueError(f"{type(x)} is an invalid argument type")