code: def make_pb_ndarray(
      arr: NDArray[t.Any],
      protocol_version: str = LATEST_PROTOCOL_VERSION,
  ) -> pb.NDArray:
      from bentoml._internal.io_descriptors.numpy import (
          npdtype_to_dtypepb_map,
      )
      from bentoml._internal.io_descriptors.numpy import (
          npdtype_to_fieldpb_map,
      )
  
      pb, _ = import_generated_stubs(protocol_version)
  
      try:
          fieldpb = npdtype_to_fieldpb_map()[arr.dtype]
          dtypepb = npdtype_to_dtypepb_map()[arr.dtype]
          return pb.NDArray(
              **{
                  fieldpb: arr.ravel().tolist(),
                  "dtype": dtypepb,
                  "shape": tuple(arr.shape),
              },
          )
      except KeyError:
          raise BentoMLException(
              f"Unsupported dtype '{arr.dtype}' for response message.",
          ) from None
  
file_path: BentoML/grpc-client/bentoml/testing/grpc/__init__.py
imports: from __future__ import annotations
  import importlib
  import traceback
  import typing
  from contextlib import ExitStack
  from contextlib import asynccontextmanager
  from typing import TYPE_CHECKING
  from ..._internal.utils import LazyLoader
  from ..._internal.utils import cached_contextmanager
  from ..._internal.utils import reserve_free_port
  from ...exceptions import BentoMLException
  from ...grpc.utils import LATEST_PROTOCOL_VERSION
  from ...grpc.utils import import_generated_stubs
  from ...grpc.utils import import_grpc
label_desc: Use image node_id 3 for calling a global function with example usage: make_pb_ndarray(arr, protocol_version) and returns: pb