code: def validate(self, instance, value):
          
          if not isinstance(value, (tuple, list, np.ndarray)):
              self.error(instance, value)
          if self.coerce:
              value = self.wrapper(value)
          valid_class = (
              self.wrapper if isinstance(self.wrapper, type) else np.ndarray
          )
          if not isinstance(value, valid_class):
              self.error(instance, value)
          allowed_kinds = ''.join(TYPE_MAPPINGS[typ] for typ in self.dtype)
          if value.dtype.kind not in allowed_kinds:
              self.error(instance, value, extra='Invalid dtype.')
          if self.shape is None:
              return value
          for shape in self.shape:
              if len(shape) != value.ndim:
                  continue
              for i, shp in enumerate(shape):
                  if shp not in ('*', value.shape[i]):
                      break
              else:
                  return value
          self.error(instance, value, extra='Invalid shape.')
docs: Determine if array is valid based on shape and dtype