class_docstr: Implementation class of an MII inference server
class_docstr_tok: ["Implementation","class","of","an","MII","inference","server"]
code: def _run_inference(self, method_name, request_proto):
      if method_name not in self.method_name_to_task:
          raise ValueError(f"unknown method: {method_name}")
  
      task = self.method_name_to_task[method_name]
      if task not in GRPC_METHOD_TABLE:
          raise ValueError(f"unknown task: {task}")
  
      task_methods = GRPC_METHOD_TABLE[task]
      args, kwargs = task_methods.unpack_request_from_proto(
          request_proto
      )
  
      start = time.time()
      with self.lock:
          response = task_methods.run_inference(
              self.inference_pipeline, args, kwargs
          )
      end = time.time()
  
      model_time = (
          self._get_model_time(
              self.inference_pipeline.model, sum_times=True
          )
          if hasattr(self.inference_pipeline, "model")
          else -1
      )
  
      return task_methods.pack_response_to_proto(
          response, end - start, model_time
      )
  
imports: import asyncio
  from concurrent import futures
  import logging
  import grpc
  from google.protobuf import empty_pb2
  from .proto import legacymodelresponse_pb2_grpc
  import sys
  import threading
  import time
  from mii.legacy.constants import GRPC_MAX_MSG_SIZE, CREATE_SESSION_METHOD, DESTROY_SESSION_METHOD, TERMINATE_METHOD, LB_MAX_WORKER_THREADS, SERVER_SHUTDOWN_TIMEOUT, TaskType
  from mii.legacy.method_table import GRPC_METHOD_TABLE
  from mii.legacy.client import create_channel
  from mii.legacy.utils import unpack_proto_query_kwargs
label_desc: Use image node_id 5 for calling the ModelResponse obj's underlying member method code with example usage: obj._run_inference(method_name, request_proto) and returns: task_methods