code: def is_valid_input_meshgrid(x, ndim):
      
      # This case is triggered in FunctionSpaceElement.__call__ if the
      # domain does not have an 'ndim' attribute. We return False and
      # continue.
      if ndim is None:
          return False
  
      if not isinstance(x, tuple):
          return False
  
      if ndim > 1:
          try:
              np.broadcast(*x)
          except (ValueError, TypeError):  # cannot be broadcast
              return False
  
      return (len(x) == ndim and
              all(isinstance(xi, np.ndarray) for xi in x) and
              all(xi.ndim == ndim for xi in x))
docs: Test if ``x`` is a `meshgrid` sequence for points in R^d.