class_docstr: This class can be used to stop generation whenever the full generation exceeds some amount of time. By default, the
  time will start being counted when you initialize this function. You can override this by passing an
  :obj:`initial_time`.
  
  Args:
      max_time (:obj:`float`):
          The maximum allowed time in seconds for the generation.
      initial_time (:obj:`float`, `optional`, defaults to :obj:`time.time()`):
          The start of the generation allowed time.
class_docstr_tok: ["This","class","can","be","used","to","stop","generation","whenever","the","full","generation","exceeds","some","amount","of","time",".","By","default",",","the","time","will","start","being","counted","when","you","initialize","this","function",".","You","can","override","this","by","passing","an",":","obj",":","`","initial_time","`",".","Args",":","max_time","(",":","obj",":","`","float","`",")",":","The","maximum","allowed","time","in","seconds","for","the","generation",".","initial_time","(",":","obj",":","`","float","`",",","`","optional","`",",","defaults","to",":","obj",":","`","time.time","(",")","`",")",":","The","start","of","the","generation","allowed","time","."]
code: def __init__(
      self, max_time: float, initial_timestamp: Optional[float] = None
  ):
      self.max_time = max_time
      self.initial_timestamp = (
          time.time()
          if initial_timestamp is None
          else initial_timestamp
      )
  
imports: import time
  from abc import ABC
  from copy import deepcopy
  from typing import Optional
  from .file_utils import add_start_docstrings
  from fastNLP.envs.imports import _NEED_IMPORT_TORCH
  from fastNLP.core.log import logger
label_desc: Use image node_id 1 to create a new MaxTimeCriteria object from inherited base classes: StoppingCriteria with example: obj = MaxTimeCriteria(max_time, initial_timestamp)