def hmm_last_checkpoint(hmm):
    """Detects the last checkpoint of the model.

  Args:
    hmm: A HiddenMarkovModel object.

  Returns:
    The number declares the last checkpoint.

  """
    cp_file = open(hmm._dir + '/checkpoint', 'r')
    fl = cp_file.readline()
    lcp = fl.split(':')[1].split('-')[-1][:-2]
    cp_file.close()
    return int(lcp)
