code: def wrap_rpc_handler(
      wrapper: t.Callable[
          ...,
          t.Callable[
              [pb.Request, BentoServicerContext],
              t.Coroutine[
                  t.Any, t.Any, pb.Response | t.Awaitable[pb.Response]
              ],
          ],
      ],
      handler: RpcMethodHandler | None,
  ) -> RpcMethodHandler | None:
      if not handler:
          return None
      if (
          not handler.request_streaming
          and not handler.response_streaming
      ):
          assert handler.unary_unary
          return handler._replace(
              unary_unary=wrapper(handler.unary_unary)
          )
      elif not handler.request_streaming and handler.response_streaming:
          assert handler.unary_stream
          return handler._replace(
              unary_stream=wrapper(handler.unary_stream)
          )
      elif handler.request_streaming and not handler.response_streaming:
          assert handler.stream_unary
          return handler._replace(
              stream_unary=wrapper(handler.stream_unary)
          )
      elif handler.request_streaming and handler.response_streaming:
          assert handler.stream_stream
          return handler._replace(
              stream_stream=wrapper(handler.stream_stream)
          )
      else:
          raise RuntimeError(
              f"RPC method handler {handler} does not exist."
          ) from None
  
imports: from __future__ import annotations
  import logging
  import typing
  from dataclasses import dataclass
  from functools import lru_cache
  from http import HTTPStatus
  from typing import TYPE_CHECKING
  from ..._internal.utils import resolve_user_filepath
  from ...exceptions import InvalidArgument
  from ._import_hook import LATEST_PROTOCOL_VERSION
  from ._import_hook import import_generated_stubs
  from ._import_hook import import_grpc
label_desc: Use image node_id 8 for calling a global function with example usage: wrap_rpc_handler(wrapper, handler) and returns: None, handler, handler, handler, handler