def resume_model_if_exist(self, directory):
    names = self.get_model_names()
    file_missing = False
    for name in names:
        path = osp.join(directory, name)
        if (not osp.exists(path)):
            file_missing = True
            break
    if file_missing:
        print('No checkpoint found, train from scratch')
        return 0
    print('Found checkpoint in "{}". Will resume training'.format(directory))
    for name in names:
        path = osp.join(directory, name)
        start_epoch = resume_from_checkpoint(path, self._models[name], self._optims[name], self._scheds[name])
    return start_epoch
def resume_model_if_exist(self, directory):
    names = self.get_model_names()
    file_missing = False
    for name in names:
        path = osp.join(directory, name)
        if (not osp.exists(path)):
            file_missing = True
            break
    if file_missing:
        print('No checkpoint found, train from scratch')
        return 0
    print('Found checkpoint in "{}". Will resume training'.format(directory))
    for name in names:
        path = osp.join(directory, name)
        start_epoch = resume_from_checkpoint(path, self._models[name], self._optims[name], self._scheds[name])
    return start_epoch