code: def _create_stopping_criteria(self, req_id, max_new_tokens=25):
      class StoppingCriteria(object):
          def __init__(
              self,
              cache,
              req_id,
              stop_token,
              max_new_tokens,
          ):
              self.req_id = req_id
              self.cache = cache
              self.max_new_tokens = max_new_tokens
              self.stop_token = stop_token
  
          def __call__(self, res):
              self.max_new_tokens -= 1
  
              if (
                  self.max_new_tokens == 0
                  or res["ids"][-1] == self.stop_token
              ):
                  self.clean_up()
                  return True
              return False
  
          def clean_up(self):
              del self.cache[self.req_id]
  
      return StoppingCriteria(
          self.context.cache,
          req_id,
          self.tokenizer.eos_token_id,
          max_new_tokens,
      )
  
file_path: serve/test/pytest/test_data/streaming/stream_handler.py
imports: import json
  import logging
  import types
  import torch
  from transformers import AutoModelForCausalLM, AutoTokenizer
  from ts.torch_handler.base_handler import BaseHandler
label_desc: Use image node_id 9 for calling the StreamingHandler obj's underlying member method code with example usage: obj._create_stopping_criteria(req_id, max_new_tokens) and returns: StoppingCriteria, False, True