code: def _check_shape(shape):
      
      if isinstance(shape, tuple):
          for dim in shape:
              if (isinstance(dim, tuple) and len(dim) == 2 and
                      isinstance(dim[0], int) and isinstance(dim[1], int)):
                  if dim[0] < 0:
                      raise ValueError("expected low dimension to be >= 0")
                  if dim[1] < 0:
                      raise ValueError("expected high dimension to be >= 0")
                  if dim[0] > dim[1]:
                      raise ValueError("expected low <= high dimensions")
              else:
                  raise TypeError("expected shape dimension to be (int, int)")
      else:
          raise TypeError("expected shape to be tuple of (int, int)")
docs: Verify that a shape has the right format.