code: def Maxout(x, num_unit):
      """
      Maxout as in the paper `Maxout Networks <http://arxiv.org/abs/1302.4389>`_.
  
      Args:
          x (tf.Tensor): a NHWC or NC tensor. Channel has to be known.
          num_unit (int): a int. Must be divisible by C.
  
      Returns:
          tf.Tensor: of shape NHW(C/num_unit) named ``output``.
      """
      input_shape = x.get_shape().as_list()
      ndim = len(input_shape)
      assert ndim == 4 or ndim == 2
      ch = input_shape[-1]
      assert ch is not None and ch % num_unit == 0
      if ndim == 4:
          x = tf.reshape(
              x,
              [
                  -1,
                  input_shape[1],
                  input_shape[2],
                  ch / num_unit,
                  num_unit,
              ],
          )
      else:
          x = tf.reshape(x, [-1, ch / num_unit, num_unit])
      return tf.reduce_max(x, ndim, name="output")
  
file_path: tensorpack/tensorpack/models/nonlin.py
imports: import tensorflow
  from ..utils.develop import log_deprecated
  from ..compat import tfv1
  from .batch_norm import BatchNorm
  from .common import VariableHolder, layer_register
  from .utils import disable_autograph
label_desc: Use image node_id 1 for calling a global function with example usage: Maxout(x, num_unit) and returns: tf