def is_cand_finished(cand, max_length, eos_id):
    """
    A candidate is finished generating if the number of decoded IDs of
    the candidate is at the max length or if the EOS ID has been generated
    """
    if len(cand) >= max_length or cand.last_decoded_id == eos_id:
        return True
    else:
        return False