code: def _gen_input_casting_func_for_tensor(
      sig: dict[str, t.Any]
  ) -> t.Callable[[ONNXArgTensorType], ext.NpNDArray]:
      elem_type = sig["elemType"]
      to_dtype = TENSORPROTO_ELEMENT_TYPE_TO_NUMPY_TYPE[elem_type]
  
      def _mapping(item: ONNXArgTensorType) -> ext.NpNDArray:
          if LazyType["ext.NpNDArray"]("numpy.ndarray").isinstance(
              item
          ):
              item = item.astype(to_dtype, copy=False)
          elif isinstance(item, list):
              item = np.array(item).astype(to_dtype, copy=False)
          elif LazyType["ext.PdDataFrame"](
              "pandas.DataFrame"
          ).isinstance(item):
              item = item.to_numpy(dtype=to_dtype)
          elif LazyType["tf.Tensor"]("tensorflow.Tensor").isinstance(
              item
          ):
              item = np.array(memoryview(item)).astype(to_dtype, copy=False)  # type: ignore
          elif LazyType["torch.Tensor"]("torch.Tensor").isinstance(
              item
          ):
              item = item.numpy().astype(to_dtype, copy=False)
          else:
              raise TypeError(
                  "`run` of ONNXRunnable only takes `numpy.ndarray`, `pd.DataFrame`, `tf.Tensor`, `torch.Tensor` or a list as input Tensor type"
              )
          return t.cast("ext.NpNDArray", item)
  
      return _mapping
  
file_path: BentoML/grpc-client/bentoml/_internal/frameworks/utils/onnx.py
imports: from __future__ import annotations
  import logging
  import typing
  from typing import TYPE_CHECKING
  from ....exceptions import BentoMLException
  from ...types import LazyType
  from ...utils.lazy_loader import LazyLoader
label_desc: Use image node_id 3 for calling a global function with example usage: _gen_input_casting_func_for_tensor(sig) and returns: _mapping, t