def generator_shortcut(model, blob_in, dim_in, dim_out, prefix, stride=1, bn=False):
    """
    defines the shortcut withing one residual block in the generator
    if bn=True: for a pre-trained network that used BN, an AffineChannel op replaces BN
    during fine-tuning.
    """

    if dim_in == dim_out:
        return blob_in
    elif bn:
        return model.Conv(blob_in, prefix + '_branch1', dim_in, dim_out, kernel=1, stride=stride)

    blob = model.Conv(blob_in, prefix + '_branch1', dim_in, dim_out, kernel=1,stride=stride, no_bias=1)
    return model.AffineChannel(blob, prefix + '_branch1_bn', dim=dim_out)