'Adds a residual block as per Arxiv 1512.03385, Figure 3'

def add_residual_block(self, num_units, mapsize=3, num_layers=2, stddev_factor=0.001):

    assert ((len(self.get_output().get_shape()) == 4) and 'Previous    layer    must    be    4-dimensional    (batch,    width,    height,    channels)')
    if (num_units != int(self.get_output().get_shape()[3])):
        self.add_conv2d(num_units, mapsize=1, stride=1, stddev_factor=1.0)
    bypass = self.get_output()
    for _ in range(num_layers):
        self.add_batch_norm()
        self.add_relu()
        self.add_conv2d(num_units, mapsize=mapsize, stride=1, stddev_factor=stddev_factor)
    self.add_sum(bypass)
    return self
