code: def np_assert(self, *, x, message, batched=False):
      if message is not None and "{name}" in message:
          message = message.format(name="", issue="{issue}")
  
      if batched or self.shape != ():
          x = np.asarray(x)
      if isinstance(x, np.ndarray):
          if (
              _normalize_type(dtype=x.dtype) != self.type
              and (
                  self.type != "float"
                  or _normalize_type(dtype=x.dtype) != "int"
              )
              and (
                  self.type != "int"
                  or (
                      _normalize_type(dtype=x.dtype) == "bool"
                      and self.num_values != 2
                  )
              )
          ):
              raise TensorforceError(
                  message.format(
                      issue=("type {} != {}".format(x.dtype, self.type))
                  )
              )
          elif x.shape[int(batched) :] != self.shape:
              raise TensorforceError(
                  message.format(
                      issue=(
                          "shape {} != {}".format(x.shape, self.shape)
                      )
                  )
              )
      elif batched or self.shape != ():
          if x.ndim >= 1 and batched:
              raise TensorforceError(
                  message.format(
                      issue=(
                          "shape {} != {}".format(
                              x.shape[1:], self.shape
                          )
                      )
                  )
              )
          else:
              raise TensorforceError(
                  message.format(
                      issue=(
                          "shape {} != {}".format(x.shape, self.shape)
                      )
                  )
              )
      elif isinstance(x, np.generic):
          if _normalize_type(dtype=x.dtype) != self.type and (
              self.type != "float"
              or _normalize_type(dtype=x.dtype) != "int"
          ):
              raise TensorforceError(
                  message.format(
                      issue=("type {} != {}".format(x.dtype, self.type))
                  )
              )
      elif self.type == "bool" and isinstance(x, bool):
          pass
      elif self.type == "int" and isinstance(x, int):
          pass
      elif self.type == "float" and isinstance(x, (int, float)):
          pass
      else:
          raise TensorforceError(
              message.format(
                  issue=("type {} != {}".format(type(x), self.type))
              )
          )
  
imports: from functools import total_ordering
  import numpy
  import tensorflow
  from tensorforce import TensorforceError, util
  from tensorforce.core.utils import tf_util
label_desc: Use image node_id 13 for calling the TensorSpec obj's underlying member method code with example usage: obj.np_assert() without return types