code: def isshape(x, nonneg=False):
      """Is x a valid 2-tuple of dimensions?
  
      If nonneg, also checks that the dimensions are non-negative.
      """
      try:
          # Assume it's a tuple of matrix dimensions (M, N)
          (M, N) = x
      except Exception:
          return False
      else:
          if isintlike(M) and isintlike(N):
              if np.ndim(M) == 0 and np.ndim(N) == 0:
                  if not nonneg or (M >= 0 and N >= 0):
                      return True
          return False
  
imports: import sys
  import operator
  import warnings
  import numpy
  from scipy._lib._util import prod
label_desc: Use image node_id 12 for calling a global function with example usage: isshape(x, nonneg) and returns: False, False, True