code: def convert_object_to_asgi_messages(
      obj: Optional[Any] = None, status_code: int = 200
  ) -> List[Message]:
      """Serializes the provided object and converts it to ASGI messages.
  
      These ASGI messages can be sent via an ASGI `send` interface to comprise an HTTP
      response.
      """
      body = None
      content_type = None
      if obj is None:
          body = b""
          content_type = b"text/plain"
      elif isinstance(obj, bytes):
          body = obj
          content_type = b"text/plain"
      elif isinstance(obj, str):
          body = obj.encode("utf-8")
          content_type = b"text/plain; charset=utf-8"
      else:
          # `separators=(",", ":")` will remove all whitespaces between separators in the
          # json string and return a minimized json string. This helps to reduce the size
          # of the response similar to Starlette's JSONResponse.
          body = json.dumps(
              jsonable_encoder(obj, custom_encoder=serve_encoders),
              separators=(",", ":"),
          ).encode()
          content_type = b"application/json"
  
      return [
          {
              "type": "http.response.start",
              "status": status_code,
              "headers": [[b"content-type", content_type]],
          },
          {"type": "http.response.body", "body": body},
      ]
  
imports: import asyncio
  import inspect
  import json
  import logging
  import pickle
  import socket
  from dataclasses import dataclass
  from typing import Any, List, Optional, Tuple, Type
  import starlette
  from fastapi.encoders import jsonable_encoder
  from starlette.types import ASGIApp, Message, Receive, Scope, Send
  from uvicorn.config import Config
  from uvicorn.lifespan.on import LifespanOn
  from ray._private.pydantic_compat import IS_PYDANTIC_2
  from ray.actor import ActorHandle
  from ray.serve._private.constants import SERVE_LOGGER_NAME
  from ray.serve._private.utils import serve_encoders
  from ray.serve.exceptions import RayServeException
label_desc: Use image node_id 2 for calling a global function with example usage: convert_object_to_asgi_messages(obj, status_code) and returns: list