class_docstr: This class can be used to stop generation whenever the full generated number of tokens exceeds `max_length`. Keep
  in mind for decoder-only type of transformers, this will include the initial prompted tokens.
  
  Args:
      max_length (`int`):
          The maximum length that the output sequence can have in number of tokens.
      max_position_embeddings (`int`, *optional*):
          The maximum model length, as defined by the model's `config.max_position_embeddings` attribute.
class_docstr_tok: ["This","class","can","be","used","to","stop","generation","whenever","the","full","generated","number","of","tokens","exceeds","`","max_length","`",".","Keep","in","mind","for","decoder-only","type","of","transformers",",","this","will","include","the","initial","prompted","tokens",".","Args",":","max_length","(","`","int","`",")",":","The","maximum","length","that","the","output","sequence","can","have","in","number","of","tokens",".","max_position_embeddings","(","`","int","`",",","*","optional","*",")",":","The","maximum","model","length",",","as","defined","by","the","model","'s","`","config.max_position_embeddings","`","attribute","."]
code: def __init__(
      self,
      max_length: int,
      max_position_embeddings: Optional[int] = None,
  ):
      self.max_length = max_length
      self.max_position_embeddings = max_position_embeddings
  
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, logging
label_desc: Use image node_id 1 to create a new MaxLengthCriteria object from inherited base classes: StoppingCriteria with example: obj = MaxLengthCriteria(max_length, max_position_embeddings)