class_docstr: ResNet model.
class_docstr_tok: ["ResNet","model","."]
docstr: Residual unit with 2 sub layers.
docstr_tok: ["Residual","unit","with","2","sub","layers","."]
code: def _residual(
      self,
      x,
      in_filter,
      out_filter,
      stride,
      activate_before_residual=False,
  ):
      """Residual unit with 2 sub layers."""
      if activate_before_residual:
          with tf.variable_scope("shared_activation"):
              x = self._layer_norm("init_bn", x)
              x = self._relu(x, self.hps.relu_leakiness)
              orig_x = x
      else:
          with tf.variable_scope("residual_only_activation"):
              orig_x = x
              x = self._layer_norm("init_bn", x)
              x = self._relu(x, self.hps.relu_leakiness)
  
      with tf.variable_scope("sub1"):
          x = self._conv("conv1", x, 3, in_filter, out_filter, stride)
  
      with tf.variable_scope("sub2"):
          x = self._layer_norm("bn2", x)
          x = self._relu(x, self.hps.relu_leakiness)
          x = self._conv(
              "conv2", x, 3, out_filter, out_filter, [1, 1, 1, 1]
          )
  
      with tf.variable_scope("sub_add"):
          if in_filter != out_filter:
              orig_x = tf.nn.avg_pool(orig_x, stride, stride, "VALID")
              orig_x = tf.pad(
                  orig_x,
                  [
                      [0, 0],
                      [0, 0],
                      [0, 0],
                      [
                          (out_filter - in_filter) // 2,
                          (out_filter - in_filter) // 2,
                      ],
                  ],
              )
          x += orig_x
  
      return x
  
imports: from collections import namedtuple
  import tensorflow
  import six
  from model import MLPnGPU
  from model import Conv2DnGPU
  from model import LinearnGPU
  from model import LayerNorm
label_desc: Use image node_id 9 for calling the ResNetTF obj's underlying member method code with example usage: obj._residual(x, in_filter, out_filter, stride, activate_before_residual) and returns: x