code: def _do_schedule_requests(self, requests: List[Request]) -> None:
      free_blocks = self.inference_engine.free_blocks
      conf_manager = self.inference_engine._config.state_manager
      for r in requests:
          if free_blocks.min().item() == 0:
              break
  
          if r.max_length <= r.seq_length:
              continue
  
          # Make sure that the engine has enough capacity to process the batch
          if (
              len(self.scheduled_requests)
              > conf_manager.max_ragged_sequence_count
          ):
              break
  
          max_batch_size = (
              conf_manager.max_ragged_batch_size - self.scheduled_length
          )
          if max_batch_size <= 0:
              break
  
          max_blocks = free_blocks - self.scheduled_req_blocks
  
          # Check capacity to mitigate the deadlock risk
          # We don't schedule requests when we find that a prompt is too long to fit to the KV cache
          if len(r.input_tokens) > 1:
              req_tokens, _ = self.inference_engine.query(
                  r.uid, len(r.input_tokens), max_blocks
              )
              if req_tokens < len(r.input_tokens):
                  break
  
          req_tokens = min(len(r.input_tokens), max_batch_size)
          req_tokens, req_blocks = self.inference_engine.query(
              r.uid, req_tokens, max_blocks
          )
  
          if req_tokens <= 0:
              continue
  
          # Decompose the prompt to fit to the max ragged batch size
          decomposed = req_tokens < len(r.input_tokens)
          remaining_tokens = r.input_tokens[req_tokens:]
          r.input_tokens = r.input_tokens[:req_tokens]
          r.last_in_prompt = not decomposed
  
          # Schedule the request
          self.scheduled_requests.append(r)
  
          self.scheduled_req_blocks += req_blocks
          self.scheduled_length += req_tokens
  
          if decomposed:
              req_remaining = copy.copy(r)
              req_remaining.input_tokens = remaining_tokens
              req_remaining.seq_length = r.seq_length + req_tokens
              req_remaining.last_in_prompt = True
  
              self.buffer.appendleft(req_remaining)
  
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 10 for calling the RaggedBatchBase obj's underlying member method code with example usage: obj._do_schedule_requests(requests) without return types