def closest_ref_length(references, hyp_len):
 ref_lens = (len(reference) for reference in references)
 closest_ref_len = min(ref_lens, key=(lambda ref_len: (abs((ref_len - hyp_len)), ref_len)))
 return closest_ref_len

def closest_ref_length ( references , hyp_len ) : ref_lens = ( len ( reference ) for reference in references ) closest_ref_len = min ( ref_lens , key = ( lambda ref_len : ( abs ( ( ref_len - hyp_len ) ) , ref_len ) ) ) return closest_ref_len
this function finds the reference that is the closest length to the hypothesis .