code: def f(
      x,
      depth1,
      depth2,
      dim="2d",
      first_batch_norm=True,
      stride=1,
      training=True,
      bottleneck=True,
      padding="SAME",
  ):
      """Applies residual function for RevNet.
  
      Args:
        x: input tensor
        depth1: Number of output channels for the first and second conv layers.
        depth2: Number of output channels for the third conv layer.
        dim: '2d' if 2-dimensional, '3d' if 3-dimensional.
        first_batch_norm: Whether to keep the first batch norm layer or not.
          Typically used in the first RevNet block.
        stride: Stride for the first conv filter. Note that this particular
          RevNet architecture only varies the stride for the first conv
          filter. The stride for the second conv filter is always set to 1.
        training: True for train phase, False for eval phase.
        bottleneck: If true, apply bottleneck 1x1 down/up sampling.
        padding: Padding for each conv layer.
  
      Returns:
        Output tensor after applying residual function for RevNet.
      """
      conv = CONFIG[dim]["conv"]
      with tf.variable_scope("f", reuse=tf.AUTO_REUSE):
          if first_batch_norm:
              net = tf.layers.batch_normalization(x, training=training)
              net = tf.nn.relu(net)
          else:
              net = x
  
          if bottleneck:
              net = conv(
                  net,
                  depth1,
                  1,
                  strides=stride,
                  padding=padding,
                  activation=None,
              )
  
              net = tf.layers.batch_normalization(
                  net, training=training
              )
              net = tf.nn.relu(net)
              net = conv(
                  net,
                  depth1,
                  3,
                  strides=1,
                  padding=padding,
                  activation=None,
              )
  
              net = tf.layers.batch_normalization(
                  net, training=training
              )
              net = tf.nn.relu(net)
              net = conv(
                  net,
                  depth2,
                  1,
                  strides=1,
                  padding=padding,
                  activation=None,
              )
          else:
              net = conv(
                  net,
                  depth2,
                  3,
                  strides=stride,
                  padding=padding,
                  activation=None,
              )
              net = tf.layers.batch_normalization(x, training=training)
              net = tf.nn.relu(net)
              net = conv(
                  net,
                  depth2,
                  3,
                  strides=stride,
                  padding=padding,
                  activation=None,
              )
  
          return net
  
imports: import functools
  from tensor2tensor.layers import common_hparams
  from tensor2tensor.utils import contrib
  from tensor2tensor.utils import registry
  from tensor2tensor.utils import t2t_model
  import tensorflow.compat.v1
  from tensorflow.compat.v1 import estimator
label_desc: Use image node_id 2 for calling a global function with example usage: f(x, depth1, depth2, dim, first_batch_norm, stride, training, bottleneck, padding) and returns: net