code: def _can_add_new_req(self, req):
      self.cache_len_list.append(
          (req.input_len + 1, req.max_output_len - 1)
      )  # hard to analysis
      self.cache_len_list.sort(key=lambda x: -x[1])
  
      left_out_len_array = np.array([e[1] for e in self.cache_len_list])
      # assert left_out_len_array.min() >= 0
      has_run_len_array = np.array([e[0] for e in self.cache_len_list])
      cum_run_len_array = np.cumsum(has_run_len_array)
      size_array = np.arange(1, len(self.cache_len_list) + 1, 1)
  
      need_max_token_num = (
          left_out_len_array * size_array + cum_run_len_array
      ).max()
      # NOTE: change here < to <=
      return (
          need_max_token_num <= self.max_total_tokens
          and len(self.cache_len_list) <= self.running_max_req_size
      )
  
file_path: ColossalAI/colossalai/legacy/inference/dynamic_batching/req_queue.py
imports: import uuid
  from typing import List
  import numpy
  from .io_struct import Batch, Req
label_desc: Use image node_id 4 for calling the ReqQueue obj's underlying member method code with example usage: obj._can_add_new_req(req) and returns: unknown