original_docstring: 
      Save a trained model, along with its optimizer, in order to be able to
      resume training
      Args:
          path (str): the directory, in which to save the checkpoints
          timestamp (bool): whether to keep only one model (latest), or keep every
              checkpoint
  
      Returns:
  
      
docstring: Save a trained model, along with its optimizer, in order to be able to
  resume training
docstring_tokens: Save a trained model along with its optimizer in order to be able to resume training
code: def save_checkpoint(state, name, path=None, timestamp=False, tag=None,
                      verbose=False):
      """
      Save a trained model, along with its optimizer, in order to be able to
      resume training
      Args:
          path (str): the directory, in which to save the checkpoints
          timestamp (bool): whether to keep only one model (latest), or keep every
              checkpoint
  
      Returns:
  
      """
      now = datetime.datetime.now().strftime("%y-%m-%d_%H:%M:%S")
  
      if tag is not None:
          if isinstance(tag, str):
              name += "_{}".format(tag)
          elif isinstance(tag, list):
              for t in tag:
                  name += "_{}".format(t)
          else:
              raise ValueError("invalid tag type!")
  
      if timestamp:
          name += "_{}".format(now)
  
      name += ".pt"
  
      if path is None:
          path = TRAINED_PATH
  
      file = os.path.join(path, name)
  
      if verbose:
          print("saving checkpoint:{} ...".format(name))
  
      torch.save(state, file)
  
      return file
code_tokens: def save_checkpoint ( state , name , path = None , timestamp = False , tag = None , verbose = False ) : now = datetime . datetime . now ( ) . strftime ( "%y-%m-%d_%H:%M:%S" ) if tag is not None : if isinstance ( tag , str ) : name += "_{}" . format ( tag ) elif isinstance ( tag , list ) : for t in tag : name += "_{}" . format ( t ) else : raise ValueError ( "invalid tag type!" ) if timestamp : name += "_{}" . format ( now ) name += ".pt" if path is None : path = TRAINED_PATH file = os . path . join ( path , name ) if verbose : print ( "saving checkpoint:{} ..." . format ( name ) ) torch . save ( state , file ) return file
short_docstring: Save a trained model, along with its optimizer, in order to be able to
  resume training
short_docstring_tokens: Save a trained model along with its optimizer in order to be able to resume training
comment: """
      Save a trained model, along with its optimizer, in order to be able to
      resume training
      Args:
          path (str): the directory, in which to save the checkpoints
          timestamp (bool): whether to keep only one model (latest), or keep every
              checkpoint
  
      Returns:
  
      """