code: def check_tensor_spec(
      tensor: "tf_ext.TensorLike",
      tensor_spec: t.Union[
          str, t.Tuple[str, ...], t.List[str], "tf_ext.UnionTensorSpec"
      ],
      class_name: t.Optional[str] = None,
  ) -> bool:
      """
      :code:`isinstance` wrapper to check spec for a given tensor.
  
      Args:
          tensor (:code:`Union[tf.Tensor, tf.EagerTensor, tf.SparseTensor, tf.RaggedTensor]`):
              tensor class to check.
          tensor_spec (:code:`Union[str, Tuple[str,...]]`):
              class used to check with :obj:`tensor`. Follows :obj:`TENSOR_CLASS_NAME`
          class_name (:code:`str`, `optional`, default to :code:`None`):
              Optional class name to pass for correct path of tensor spec. If none specified,
              then :code:`class_name` will be determined via given spec class.
  
      Returns:
          `bool` if given tensor match a given spec.
      """
      if tensor_spec is None:
          raise BentoMLException("`tensor` should not be None")
      tensor_cls = type(tensor).__name__
      if isinstance(tensor_spec, str):
          return tensor_cls == tensor_spec.split(".")[-1]
      elif isinstance(tensor_spec, (list, tuple, set)):
          return all(check_tensor_spec(tensor, k) for k in tensor_spec)
      else:
          if class_name is None:
              class_name = (
                  str(tensor_spec.__class__)
                  .replace("<class '", "")
                  .replace("'>", "")
              )
          return LazyType["tf_ext.TensorSpec"](class_name).isinstance(
              tensor
          )
  
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 4 for calling a global function with example usage: check_tensor_spec(tensor, tensor_spec, class_name) and returns: unknown, all, LazyType