code: def check_shape(shape, /, **kwargs):
      """
      For each *key, value* pair in *kwargs*, check that *value* has the shape *shape*;
      if not, raise an appropriate ValueError.
  
      *None* in the shape is treated as a "free" size that can have any length.
      e.g. (None, 2) -> (N, 2)
  
      The values checked must be numpy arrays.
  
      Examples
      --------
      To check for (N, 2) shaped arrays
  
      >>> _api.check_shape((None, 2), arg=arg, other_arg=other_arg)
      """
      for k, v in kwargs.items():
          data_shape = v.shape
  
          if len(data_shape) != len(shape) or any(
              s != t and t is not None
              for s, t in zip(data_shape, shape)
          ):
              dim_labels = iter(
                  itertools.chain(
                      "NMLKJIH", (f"D{i}" for i in itertools.count())
                  )
              )
              text_shape = ", ".join(
                  [
                      str(n) if n is not None else next(dim_labels)
                      for n in shape[::-1]
                  ][::-1]
              )
              if len(shape) == 1:
                  text_shape += ","
  
              raise ValueError(
                  f"{k!r} must be {len(shape)}D with shape ({text_shape}), "
                  f"but your input has shape {v.shape}"
              )
  
imports: import functools
  import itertools
  import re
  import sys
  import warnings
  from .deprecation import deprecated, warn_deprecated, rename_parameter, delete_parameter, make_keyword_only, deprecate_method_override, deprecate_privatize_attribute, suppress_matplotlib_deprecation_warning, MatplotlibDeprecationWarning
label_desc: Use image node_id 3 for calling a global function with example usage: check_shape() without return types