code: def assert_patch_size(
      patch_size: Union[int, tuple], shape: Tuple[int, ...]
  ) -> None:
      """
      Assert that patch size is compatible with given image shape.
  
      Parameters
      ----------
      patch_size: integer
          The size of the patch_size, assumed to tbe squared.
      input_shape: Tuple[int...]
          the shape of the input.
  
      Returns
      -------
      None
      """
  
      if isinstance(patch_size, int):
          patch_size = (patch_size,)
      patch_size = np.array(patch_size)
  
      assert isinstance(patch_size, np.ndarray)
      if len(patch_size) == 1 and len(shape) != 1:
          patch_size = tuple(patch_size for _ in shape)
      elif patch_size.ndim != 1:
          raise ValueError(
              "patch_size has to be either a scalar or a 1d-sequence"
          )
      elif len(patch_size) != len(shape):
          raise ValueError(
              "patch_size sequence length does not match shape length"
              f" (len(patch_size) != len(shape))"
          )
      patch_size = tuple(patch_size)
      if np.prod(shape) % np.prod(patch_size) != 0:
          raise ValueError(
              "Set 'patch_size' so that the input shape modulo remainder returns 0"
              f" [np.prod({shape}) % np.prod({patch_size}) != 0"
              f" => {np.prod(shape)} % {np.prod(patch_size)} != 0]"
          )
  
file_path: Quantus/quantus/helpers/asserts.py
imports: from typing import Callable, Tuple, Sequence, Union
  import numpy
label_desc: Use image node_id 2 for calling a global function with example usage: assert_patch_size(patch_size, shape) without return types