code: def _retrieve_input_data(conn):
      """
      MSG Frame Format:
  
      | parameter_name |
      | content_type |
      | input data in bytes |
      """
      decode_req = os.environ.get("TS_DECODE_INPUT_REQUEST")
      length = _retrieve_int(conn)
      if length == -1:
          return None
  
      model_input = {}
      model_input["name"] = _retrieve_buffer(conn, length).decode(
          "utf-8"
      )
  
      length = _retrieve_int(conn)
      content_type = _retrieve_buffer(conn, length).decode("utf-8")
      model_input["contentType"] = content_type
  
      length = _retrieve_int(conn)
      value = _retrieve_buffer(conn, length)
      if content_type == "application/json" and (
          decode_req is None or decode_req == "true"
      ):
          try:
              model_input["value"] = json.loads(value.decode("utf-8"))
  
          except Exception as e:
              model_input["value"] = value
              logging.warning(
                  "Failed json decoding of input data. Forwarding encoded payload",
                  exc_info=True,
              )
  
      elif content_type.startswith("text") and (
          decode_req is None or decode_req == "true"
      ):
          try:
              model_input["value"] = value.decode("utf-8")
  
          except Exception as e:
              model_input["value"] = value
              logging.warning(
                  "Failed utf-8 decoding of input data. Forwarding encoded payload",
                  exc_info=True,
              )
  
      else:
          model_input["value"] = value
  
      return model_input
  
imports: import io
  import json
  import logging
  import os
  import struct
  import sys
  import time
  from builtins import bytearray, bytes
  import torch
  from ts.utils.util import deprecated
label_desc: Use image node_id 12 for calling a global function with example usage: _retrieve_input_data(conn) and returns: model_input, None