code: def batch_flatten(x):
      """
      Flatten the tensor except the first dimension.
      """
      shape = x.get_shape().as_list()[1:]
      if None not in shape:
          return tf.reshape(x, [-1, int(np.prod(shape))])
      return tf.reshape(x, tf.stack([tf.shape(x)[0], -1]))
  
file_path: tensorpack/examples/GAN/ConditionalGAN-mnist.py
imports: import argparse
  import numpy
  import os
  import cv2
  import tensorflow
  from tensorpack import *
  from tensorpack.dataflow import dataset
  from tensorpack.tfutils.scope_utils import auto_reuse_variable_scope
  from tensorpack.utils.viz import interactive_imshow, stack_patches
  from GAN import GANModelDesc, GANTrainer, RandomZData
label_desc: Use image node_id 1 for calling a global function with example usage: batch_flatten(x) and returns: tf, tf