def _closest_ref_length(references, trans_length):
    """Find the reference that has the closest length to the translation.

    Parameters
    ----------
    references: list(list(str))
        A list of references.
    trans_length: int
        Length of the translation.

    Returns
    -------
    closest_ref_len: int
        Length of the reference that is closest to the translation.
    """
    ref_lengths = (len(reference) for reference in references)
    closest_ref_len = min(ref_lengths,
                          key=lambda ref_length: (abs(ref_length - trans_length), ref_length))

    return closest_ref_len