code: def cast_py_args_to_tf_function_args(
      signature: list[tf_ext.TensorSpec],
      *args: t.Any,
      **kwargs: t.Any,
  ) -> tuple[t.Any, ...]:
      """
      Cast python arguments (args, kwargs) to tensorflow function arguments.
  
      Args:
          signature (:code:`list[tf.TensorSpec]`):
              signature of the tensorflow function.
          *args (:code:`t.Any`):
              positional arguments of the Python function.
          **kwargs (:code:`t.Any`):
              keyword arguments of the Python function.
      """
      import inspect
  
      parameters = [
          inspect.Parameter(
              name=s.name,
              kind=inspect.Parameter.POSITIONAL_OR_KEYWORD,
          )
          for s in signature
      ]
      func_sig = inspect.Signature(parameters=parameters)
      bound_args = func_sig.bind(*args, **kwargs)
      if len(bound_args.arguments) != len(signature):
          raise ValueError(
              f"Expected {len(signature)} arguments, got {len(bound_args.arguments)}"
          )
  
      trans_args: t.Tuple[t.Any, ...] = tuple(
          cast_tensor_by_spec(arg, spec)
          for arg, spec in zip(bound_args.arguments.values(), signature)
      )
      return trans_args
  
imports: from __future__ import annotations
  import importlib.metadata
  import importlib.util
  import logging
  import typing
  from typing import TYPE_CHECKING
  from bentoml.exceptions import BentoMLException
  from ...types import LazyType
  from ...utils.lazy_loader import LazyLoader
label_desc: Use image node_id 6 for calling a global function with example usage: cast_py_args_to_tf_function_args(signature) and returns: trans_args