<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _convert_distance_names_to_functions(distance):
 """ Convert function names in a composite distance function into function handles. """

    dist_out = _copy.deepcopy(distance)

    for i, d in enumerate(distance):
        _, dist, _ = d
        if isinstance(dist, str):
            try:
                dist_out[i][1] = _tc.distances.__dict__[dist]
            except:
                raise ValueError("Distance '{}' not recognized.".format(dist))

    return dist_out