def add_norm_layer(layer):
    nonlocal norm_type
    if norm_type.startswith('spectral'):
        layer = spectral_norm(layer)
        subnorm_type = norm_type[len('spectral'):]
    if ((subnorm_type == 'none') or (len(subnorm_type) == 0)):
        return layer
    if (getattr(layer, 'bias', None) is not None):
        delattr(layer, 'bias')
        layer.register_parameter('bias', None)
    if (subnorm_type == 'batch'):
        norm_layer = nn.BatchNorm2d(get_out_channel(layer), affine=True)
    elif (subnorm_type == 'sync_batch'):
        norm_layer = SynchronizedBatchNorm2d(get_out_channel(layer), affine=True)
    elif (subnorm_type == 'instance'):
        norm_layer = nn.InstanceNorm2d(get_out_channel(layer), affine=False)
    else:
        raise ValueError(('normalization layer %s is not recognized' % subnorm_type))
    return nn.Sequential(layer, norm_layer)
def add_norm_layer(layer):
    nonlocal norm_type
    if norm_type.startswith('spectral'):
        layer = spectral_norm(layer)
        subnorm_type = norm_type[len('spectral'):]
    if ((subnorm_type == 'none') or (len(subnorm_type) == 0)):
        return layer
    if (getattr(layer, 'bias', None) is not None):
        delattr(layer, 'bias')
        layer.register_parameter('bias', None)
    if (subnorm_type == 'batch'):
        norm_layer = nn.BatchNorm2d(get_out_channel(layer), affine=True)
    elif (subnorm_type == 'sync_batch'):
        norm_layer = SynchronizedBatchNorm2d(get_out_channel(layer), affine=True)
    elif (subnorm_type == 'instance'):
        norm_layer = nn.InstanceNorm2d(get_out_channel(layer), affine=False)
    else:
        raise ValueError(('normalization layer %s is not recognized' % subnorm_type))
    return nn.Sequential(layer, norm_layer)