docstr: Return the location of the latest model and training state files.
  If there isn't a valid checkpoint then return None.
docstr_tok: ["Return","the","location","of","the","latest","model","and","training","state","files",".","If","there","is","n't","a","valid","checkpoint","then","return","None","."]
code: def find_latest_checkpoint(self):
      """
      Return the location of the latest model and training state files.
      If there isn't a valid checkpoint then return None.
      """
      have_checkpoint = self._serialization_dir is not None and any(
          "model_state_epoch_" in x
          for x in os.listdir(self._serialization_dir)
      )
  
      if not have_checkpoint:
          return None
  
      serialization_files = os.listdir(self._serialization_dir)
      model_checkpoints = [
          x for x in serialization_files if "model_state_epoch" in x
      ]
      # Get the last checkpoint file.  Epochs are specified as either an
      # int (for end of epoch files) or with epoch and timestamp for
      # within epoch checkpoints, e.g. 5.2018-02-02-15-33-42
      found_epochs = [
          # pylint: disable=anomalous-backslash-in-string
          re.search("model_state_epoch_([0-9\.\-]+)\.th", x).group(1)
          for x in model_checkpoints
      ]
      int_epochs = []
      for epoch in found_epochs:
          pieces = epoch.split(".")
          if len(pieces) == 1:
              # Just a single epoch without timestamp
              int_epochs.append([int(pieces[0]), 0])
          else:
              # has a timestamp
              int_epochs.append([int(pieces[0]), pieces[1]])
      last_epoch = sorted(int_epochs, reverse=True)[0]
      if last_epoch[1] == 0:
          epoch_to_load = unicode(last_epoch[0])
      else:
          epoch_to_load = "{0}.{1}".format(last_epoch[0], last_epoch[1])
  
      model_path = os.path.join(
          self._serialization_dir,
          "model_state_epoch_{}.th".format(epoch_to_load),
      )
      training_state_path = os.path.join(
          self._serialization_dir,
          "training_state_epoch_{}.th".format(epoch_to_load),
      )
  
      return (model_path, training_state_path)
  
imports: from __future__ import with_statement
  from __future__ import division
  from __future__ import absolute_import
  import logging
  import os
  import shutil
  import time
  import re
  import datetime
  import traceback
  import torch
  import torch.optim.lr_scheduler
  from torch.nn.parallel import replicate, parallel_apply
  from torch.nn.parallel.scatter_gather import scatter_kwargs, gather
  from allennlp.common import Params
  from allennlp.common.checks import ConfigurationError
  from allennlp.common.util import peak_memory_mb, gpu_memory_mb
  from allennlp.common.tqdm import Tqdm
  from allennlp.data.instance import Instance
  from allennlp.data.iterators.data_iterator import DataIterator
  from allennlp.models.model import Model
  from allennlp.nn import util
  from allennlp.training.learning_rate_schedulers import LearningRateScheduler
  from allennlp.training.optimizers import Optimizer
label_desc: Use image node_id 19 for calling the Trainer obj's underlying member method code with example usage: obj.find_latest_checkpoint() and returns: model_path,  training_state_path, None