class_docstr: Implementation class of an MII inference server
class_docstr_tok: ["Implementation","class","of","an","MII","inference","server"]
code: def GeneratorReply(self, request, context):
      task_methods = self._get_task_methods("GeneratorReply")
  
      prompts, kwargs = task_methods.unpack_request_from_proto(request)
      uids_running, uids_complete_order, responses = [], [], []
  
      # Put requests for all prompts into the pipeline
      for p in prompts:
          request_kwargs = kwargs.copy()
          uid = self.inference_pipeline.put_request(p, request_kwargs)
          uids_running.append(uid)
  
      # Get responses from the pipeline as they are ready, flush finished uids
      # so new requests can be processed
      while uids_running:
          uid, response = self.inference_pipeline.get_response()
          # TODO: Ugly hack for multi-threading. Will be fixed when we refactor these methods
          if uid == -1:
              uid = uids_running[0]
          responses.append(response)
          self.inference_pipeline.flush_uid(uid)
          uids_complete_order.append(uids_running.index(uid))
          uids_running.remove(uid)
  
      # Sort responses in the order of prompts
      responses = [
          r
          for idx, r in sorted(
              zip(uids_complete_order, responses),
              key=lambda pair: pair[0],
          )
      ]
  
      return task_methods.pack_response_to_proto(responses)
  
imports: import asyncio
  import queue
  import sys
  import threading
  from concurrent import futures
  from typing import Dict
  import grpc
  from google.protobuf import empty_pb2
  from mii.backend.client import create_channel
  from mii.constants import GenerationFinishReason, GRPC_MAX_MSG_SIZE, TERMINATE_METHOD, LB_MAX_WORKER_THREADS, SERVER_SHUTDOWN_TIMEOUT, STREAM_RESPONSE_QUEUE_TIMEOUT
  from mii.grpc_related.proto import modelresponse_pb2_grpc
  from mii.grpc_related.task_methods import TASK_METHODS_DICT, TaskMethods
label_desc: Use image node_id 3 for calling the ModelResponse obj's underlying member method code with example usage: obj.GeneratorReply(request, context) and returns: task_methods