docstr: Logic for handling requests
docstr_tok: ["Logic","for","handling","requests"]
code: def _step(self):
      """
      Logic for handling requests
      """
  
      if self.running_batch is None:
          new_batch = self.req_queue.generate_new_batch(
              self.running_batch
          )
          if new_batch is not None:
              self.stats_tool.count_prompt_tokens(new_batch)
              self.running_batch = new_batch
              yield from self._prefill_batch(self.running_batch)
              self._filter_runing_batch()
              self.has_wait_tokens = 0
          return
  
      if self.has_wait_tokens < self.max_wait_tokens:
          self.stats_tool.count_output_tokens(self.running_batch)
          yield from self._decode_batch(self.running_batch)
          self._filter_runing_batch()
          self.has_wait_tokens += 1
          return
      else:
          new_mini_batch = self.req_queue.generate_new_batch(
              self.running_batch
          )
          if new_mini_batch is not None:
              self.stats_tool.count_prompt_tokens(new_mini_batch)
              yield from self._prefill_batch(new_mini_batch)
              if not new_mini_batch.is_clear():
                  self._merge_batch(self.running_batch, new_mini_batch)
                  self.running_batch.merge(new_mini_batch)
              self.has_wait_tokens = 0
  
          else:
              self.stats_tool.count_output_tokens(self.running_batch)
              yield from self._decode_batch(self.running_batch)
              self._filter_runing_batch()
              self.has_wait_tokens += 1
  
      return
  
imports: import time
  from typing import List
  from .dynamic_batching.get_tokenizer import get_tokenizer
  from .dynamic_batching.infer_batch import InferBatch
  from .dynamic_batching.io_struct import Batch, Req
  from .dynamic_batching.req_queue import ReqQueue
  from .dynamic_batching.sampling_params import SamplingParams
  from .dynamic_batching.stats import Stats
  from .tensor_parallel import TPInferEngine
label_desc: Use image node_id 6 for calling the DynamicBatchManager obj's underlying member method code with example usage: obj._step() without return types