code: def validate_dim(x, max_dim=None, min_dim=None, var_name="var"):
      # Calculate dimension
      if isinstance(x, tf.Tensor):
          dim = len(x.get_shape().as_list())
      elif type(x) in [np.ndarray, np.array, list]:
          dim = np.ndim(x)
      else:
          # TODO: check hdf5, panda
          return
      # Verify dimension conditions
      if max_dim == min_dim:
          if dim != max_dim:
              raise ValueError("%s must be %s-D." % (var_name, max_dim))
      else:
          if min_dim and dim < min_dim:
              raise ValueError(
                  "%s must be at least %s-D." % (var_name, min_dim)
              )
          elif max_dim and dim > max_dim:
              raise ValueError(
                  "%s must be %s-D or less." % (var_name, max_dim)
              )
  
imports: from __future__ import division, print_function, absolute_import
  import six
  import string
  import random
  import numpy
  import tensorflow.compat.v1
  from tensorflow.python import pywrap_tensorflow
  import tflearn.variables
label_desc: Use image node_id 35 for calling a global function with example usage: validate_dim(x, max_dim, min_dim, var_name) without return types