code: def from_ts_grpc(data: PredictionResponse) -> InferResponse:
      """Converts the Torchserve gRPC PredictionResponse object to InferResponse message"""
      decoded_data = json.loads(data.prediction.decode("utf-8"))
      infer_outputs = [
          InferOutput(
              name=output["name"],
              shape=list(output["shape"]),
              datatype=output["datatype"],
              data=output["data"],
          )
          for output in decoded_data["outputs"]
      ]
      response_id = decoded_data.get("id")
      infer_response = InferResponse(
          model_name=decoded_data["model_name"],
          response_id=response_id,
          infer_outputs=infer_outputs,
          from_grpc=True,
      )
      return infer_response.to_grpc()
  
file_path: serve/kubernetes/kserve/kserve_wrapper/gprc_utils.py
imports: import base64
  import json
  from typing import Union
  from inference_pb2 import PredictionResponse, PredictionsRequest
  from kserve.errors import InvalidInput
  from kserve.protocol.grpc.grpc_predict_v2_pb2 import InferTensorContents, ModelInferRequest
  from kserve.protocol.infer_type import InferOutput, InferRequest, InferResponse
label_desc: Use image node_id 3 for calling a global function with example usage: from_ts_grpc(data) and returns: infer_response