class_docstr: This class can be used to stop generation whenever the generated number of tokens exceeds `max_new_tokens`. Keep in
  mind for decoder-only type of transformers, this will **not** include the initial prompted tokens. This is very
  close to `MaxLengthCriteria` but ignores the number of initial tokens.
  
  Args:
      start_length (`int`):
          The number of initial tokens.
      max_new_tokens (`int`):
          The maximum number of tokens to generate.
class_docstr_tok: ["This","class","can","be","used","to","stop","generation","whenever","the","generated","number","of","tokens","exceeds","`","max_new_tokens","`",".","Keep","in","mind","for","decoder-only","type","of","transformers",",","this","will","*","*","not","*","*","include","the","initial","prompted","tokens",".","This","is","very","close","to","`","MaxLengthCriteria","`","but","ignores","the","number","of","initial","tokens",".","Args",":","start_length","(","`","int","`",")",":","The","number","of","initial","tokens",".","max_new_tokens","(","`","int","`",")",":","The","maximum","number","of","tokens","to","generate","."]
code: def __init__(self, start_length: int, max_new_tokens: int):
      warnings.warn(
          "The class `MaxNewTokensCriteria` is deprecated. "
          f"Please use `MaxLengthCriteria(max_length={start_length + max_new_tokens})` "
          "with `max_length = start_length + max_new_tokens` instead.",
          FutureWarning,
      )
      self.start_length = start_length
      self.max_new_tokens = max_new_tokens
      self.max_length = start_length + max_new_tokens
  
imports: import time
  import warnings
  from abc import ABC
  from copy import deepcopy
  from typing import Optional
  import torch
  from .utils import add_start_docstrings
label_desc: Use image node_id 1 to create a new MaxNewTokensCriteria object from inherited base classes: StoppingCriteria with example: obj = MaxNewTokensCriteria(start_length, max_new_tokens)