code: def prepare_X(
      X, target_ndim, max_dim=None, min_dim=None, debug_msg="Data"
  ):
      # Validate the dimension
      validate_dim(X, max_dim, min_dim)
  
      X_ndim = np.ndim(X)
      # Reshape to the desired dimension
      if X_ndim < target_ndim:
          for i in range(target_ndim - X_ndim):
              try:
                  X = np.expand_dims(X, axis=0)
              except Exception:
                  raise Exception(
                      debug_msg
                      + " shape mismatch (too few dimensions)."
                  )
      elif X_ndim > target_ndim:
          for i in range(X_ndim - target_ndim):
              try:
                  X = np.reshape(X, newshape=np.shape(X)[:-1])
              except Exception:
                  raise Exception(
                      debug_msg
                      + " shape mismatch (too many dimensions)."
                  )
      return X, X_ndim
  
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 36 for calling a global function with example usage: prepare_X(X, target_ndim, max_dim, min_dim, debug_msg) and returns: X,  X_ndim