def bottleneck_block_v1(cnn, depth, depth_bottleneck, stride):
    """Bottleneck block with identity short-cut for ResNet v1.

  Args:
    cnn: the network to append bottleneck blocks.
    depth: the number of output filters for this bottleneck block.
    depth_bottleneck: the number of bottleneck filters for this block.
    stride: Stride used in the first layer of the bottleneck block.
  """
    input_layer = cnn.top_layer
    in_size = cnn.top_size
    name_key = "resnet_v1"
    name = name_key + str(cnn.counts[name_key])
    cnn.counts[name_key] += 1

    with tf.variable_scope(name):
        if depth == in_size:
            if stride == 1:
                shortcut = input_layer
            else:
                shortcut = cnn.apool(
                    1,
                    1,
                    stride,
                    stride,
                    input_layer=input_layer,
                    num_channels_in=in_size)
        else:
            shortcut = cnn.conv(
                depth,
                1,
                1,
                stride,
                stride,
                activation=None,
                use_batch_norm=True,
                input_layer=input_layer,
                num_channels_in=in_size,
                bias=None)
        cnn.conv(
            depth_bottleneck,
            1,
            1,
            stride,
            stride,
            input_layer=input_layer,
            num_channels_in=in_size,
            use_batch_norm=True,
            bias=None)
        cnn.conv(
            depth_bottleneck,
            3,
            3,
            1,
            1,
            mode="SAME_RESNET",
            use_batch_norm=True,
            bias=None)
        res = cnn.conv(
            depth, 1, 1, 1, 1, activation=None, use_batch_norm=True, bias=None)
        output = tf.nn.relu(shortcut + res)
        cnn.top_layer = output
        cnn.top_size = depth
Bottleneck block with identity short-cut for ResNet v1.

  Args:
    cnn: the network to append bottleneck blocks.
    depth: the number of output filters for this bottleneck block.
    depth_bottleneck: the number of bottleneck filters for this block.
    stride: Stride used in the first layer of the bottleneck block.