code: def validate_stopping_criteria(
      stopping_criteria: StoppingCriteriaList, max_length: int
  ) -> StoppingCriteriaList:
      stopping_max_length = stopping_criteria.max_length
      new_stopping_criteria = deepcopy(stopping_criteria)
      if (
          stopping_max_length is not None
          and stopping_max_length != max_length
      ):
          logger.rank_zero_warning(
              "You set different `max_length` for stopping criteria and `max_length` parameter",
              UserWarning,
          )
      elif stopping_max_length is None:
          new_stopping_criteria.append(
              MaxLengthCriteria(max_length=max_length)
          )
      return new_stopping_criteria
  
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 for calling a global function with example usage: validate_stopping_criteria(stopping_criteria, max_length) and returns: new_stopping_criteria