code: def encode_response_headers(resp_hdr_map):
      msg = bytearray()
      msg += struct.pack("!i", len(resp_hdr_map))
      for k, v in resp_hdr_map.items():
          msg += struct.pack("!i", len(k.encode("utf-8")))
          msg += k.encode("utf-8")
          msg += struct.pack("!i", len(v.encode("utf-8")))
          msg += v.encode("utf-8")
      return msg
  
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 2 for calling a global function with example usage: encode_response_headers(resp_hdr_map) and returns: msg