code: def schedule_requests(self) -> None:
      while not self.request_queue.empty():
          r = self.request_queue.get_nowait()
          self.buffer.append(r)
  
      # Run next token generation first
      next_token_gen_reqs = []
      prompt_reqs = []
  
      for r in self.buffer:
          if r.is_flush_request:
              self.scheduled_requests.append(r)
          else:
              if len(r.input_tokens) == 1:
                  next_token_gen_reqs.append(r)
              else:
                  prompt_reqs.append(r)
  
      # We want to process next token generation first
      self._do_schedule_requests(next_token_gen_reqs)
      self._do_schedule_requests(prompt_reqs)
  
      if len(self.buffer) > 0 and len(self.scheduled_requests) == 0:
          print(
              "Deadlock detected. Resetting KV cache and recomputing requests. Consider limiting number of concurrent requests or decreasing max lengths of prompts/generations."
          )
          self.scheduled_requests = RequestBatch()
          self.reset_request_status()
      else:
          scheduled_requests_ids = set(
              id(r) for r in self.scheduled_requests
          )
          self.buffer = deque(
              [
                  r
                  for r in self.buffer
                  if id(r) not in scheduled_requests_ids
              ]
          )
  
imports: import copy
  import gc
  import os
  import queue
  import random
  import threading
  import time
  from collections import deque, defaultdict
  from functools import cached_property
  from typing import Dict, Tuple, List, Any, Union, DefaultDict
  import torch
  import ujson
  import zmq
  from deepspeed.accelerator import get_accelerator
  from deepspeed.utils.timer import SynchronizedWallClockTimer
  from mii.batching.constants import TOP_K_NAME, TOP_P_NAME, TEMP_NAME, SAMPLER_NAME, STOP_NAME
  from mii.batching.data_classes import Response, Request, RequestBatch
  from mii.batching.generation.logit_processors import TopPLogitProcessor, TopKLogitProcessor, TemperatureLogitProcessor
  from mii.batching.generation.samplers import LogitsSampler, GreedySampler
  from mii.batching.generation.stop_criterion import EosGenerationStopCriterion, TokenStopCriterion
  from mii.batching.postprocess import run_batch_logit_processing, run_batch_sampler, run_batch_stop_criterion
  from mii.batching.utils import sync_debug, profiler
  from mii.config import GenerateParamsConfig
  from mii.constants import GenerationFinishReason, ZMQ_RECV_TIMEOUT
  from mii.logging import logger
label_desc: Use image node_id 11 for calling the RaggedBatchBase obj's underlying member method code with example usage: obj.schedule_requests() without return types