code: def parse_dict_to_proto(
      obj: JSONType,
      msg: _message.Message,
      json_encoder: type[json.JSONEncoder] = DefaultJsonEncoder,
  ) -> t.Any:
      if obj is None:
          # this function is an identity op for the msg if obj is None.
          return msg
  
      from google.protobuf.json_format import ParseDict
  
      if isinstance(obj, (dict, str, list, float, int, bool)):
          # ParseDict handles google.protobuf.Struct type
          # directly if given object has a supported type
          ParseDict(obj, msg)
      else:
          # If given object doesn't have a supported type, we will
          # use given JSON encoder to convert it to dictionary
          # and then parse it to google.protobuf.Struct.
          # Note that if a custom JSON encoder is used, it mustn't
          # take any arguments.
          ParseDict(json_encoder().default(obj), msg)
      return msg
  
imports: from __future__ import annotations
  import dataclasses
  import json
  import logging
  import typing
  import attr
  from starlette.requests import Request
  from starlette.responses import Response
  from ...exceptions import BadInput
  from ...exceptions import InvalidArgument
  from ..service.openapi import REF_PREFIX
  from ..service.openapi import SUCCESS_DESCRIPTION
  from ..service.openapi.specification import MediaType
  from ..service.openapi.specification import Schema
  from ..types import LazyType
  from ..utils import LazyLoader
  from ..utils import bentoml_cattr
  from ..utils.http import set_cookies
  from ..utils.pkg import pkg_version_info
  from .base import IODescriptor
label_desc: Use image node_id 1 for calling a global function with example usage: parse_dict_to_proto(obj, msg, json_encoder) and returns: msg, msg