jiahuimbzuai/CoQuIR huggingface dataset:
//  [python]
def __init__(self, n_in_channels, n_mel_channels, d_i, n_layers, n_channels, kernel_size=3):
        super().__init__()
        assert(kernel_size % 2 == 1)
        assert(n_channels % 2 == 0)
        self.n_layers = n_layers
        self.n_channels = n_channels
        self.in_layers = torch.nn.ModuleList()
        self.res_skip_layers = torch.nn.ModuleList()

        start = torch.nn.Conv1d(n_in_channels, n_channels, 1)
        start = torch.nn.utils.parametrizations.weight_norm(start, name='weight')
        self.start = start

        # Initializing last layer to 0 makes the affine coupling layers
        # do nothing at first.  This helps with training stability
        end = torch.nn.Conv1d(n_channels, 2 * n_in_channels, 1)
        end.weight.data.zero_()
        end.bias.data.zero_()
        self.end = end

        cond_layer = torch.nn.Conv1d(n_mel_channels, 2*n_channels*n_layers, 1)
        self.cond_layer = torch.nn.utils.parametrizations.weight_norm(cond_layer, name='weight')

        for i in range(n_layers):
            dilation = d_i ** i
            padding = int((kernel_size*dilation - dilation)/2)
            in_layer = torch.nn.Conv1d(n_channels, 2*n_channels, kernel_size,
                                       dilation=dilation, padding=padding)
            in_layer = torch.nn.utils.parametrizations.weight_norm(in_layer, name='weight')
            self.in_layers.append(in_layer)

            # last one is not necessary
            if i < n_layers - 1:
                res_skip_channels = 2*n_channels
            else:
                res_skip_channels = n_channels
            res_skip_layer = torch.nn.Conv1d(n_channels, res_skip_channels, 1)
            res_skip_layer = torch.nn.utils.parametrizations.weight_norm(
                res_skip_layer, name='weight')
            self.res_skip_layers.append(res_skip_layer)
//  [python]
def __init__(self, n_in_channels, n_mel_channels, n_layers, n_channels,
                 kernel_size):
        super(WN, self).__init__()
        assert (kernel_size % 2 == 1)
        assert (n_channels % 2 == 0)
        self.n_layers = n_layers
        self.n_channels = n_channels
        self.in_layers = torch.nn.ModuleList()
        self.res_skip_layers = torch.nn.ModuleList()
        self.cond_layers = torch.nn.ModuleList()

        start = torch.nn.Conv1d(n_in_channels, n_channels, 1)
        start = torch.nn.utils.weight_norm(start, name='weight')
        self.start = start

        # Initializing last layer to 0 makes the affine coupling layers
        # do nothing at first.  This helps with training stability
        end = torch.nn.Conv1d(n_channels, 2 * n_in_channels, 1)
        end.weight.data.zero_()
        end.bias.data.zero_()
        self.end = end

        for i in range(n_layers):
            dilation = 2**i
            padding = int((kernel_size * dilation - dilation) / 2)
            in_layer = torch.nn.Conv1d(n_channels,
                                       2 * n_channels,
                                       kernel_size,
                                       dilation=dilation,
                                       padding=padding)
            in_layer = torch.nn.utils.weight_norm(in_layer, name='weight')
            self.in_layers.append(in_layer)

            cond_layer = torch.nn.Conv1d(n_mel_channels, 2 * n_channels, 1)
            cond_layer = torch.nn.utils.weight_norm(cond_layer, name='weight')
            self.cond_layers.append(cond_layer)

            # last one is not necessary
            if i < n_layers - 1:
                res_skip_channels = 2 * n_channels
            else:
                res_skip_channels = n_channels
            res_skip_layer = torch.nn.Conv1d(n_channels, res_skip_channels, 1)
            res_skip_layer = torch.nn.utils.weight_norm(res_skip_layer,
                                                        name='weight')
            self.res_skip_layers.append(res_skip_layer)
//  [python]
def __init__(self, n_in_channels, n_mel_channels, n_layers, n_channels,
                 kernel_size):
        super(WN, self).__init__()
        assert (kernel_size % 2 == 1)
        assert (n_channels % 2 == 0)
        self.n_layers = n_layers
        self.n_channels = n_channels
        self.in_layers = torch.nn.ModuleList()
        self.res_skip_layers = torch.nn.ModuleList()
        self.cond_layers = torch.nn.ModuleList()

        start = torch.nn.Conv1d(n_in_channels, n_channels, 1)
        start = torch.nn.utils.parametrizations.weight_norm(start, name='weight')
        self.start = start

        # Initializing last layer to 0 makes the affine coupling layers
        # do nothing at first.  This helps with training stability
        end = torch.nn.Conv1d(n_channels, 2 * n_in_channels, 1)
        end.weight.data.zero_()
        end.bias.data.zero_()
        self.end = end

        for i in range(n_layers):
            dilation = 2**i
            padding = int((kernel_size * dilation - dilation) / 2)
            in_layer = torch.nn.Conv1d(n_channels,
                                       2 * n_channels,
                                       kernel_size,
                                       dilation=dilation,
                                       padding=padding)
            in_layer = torch.nn.utils.parametrizations.weight_norm(in_layer, name='weight')
            self.in_layers.append(in_layer)

            cond_layer = torch.nn.Conv1d(n_mel_channels, 2 * n_channels, 1)
            cond_layer = torch.nn.utils.parametrizations.weight_norm(cond_layer, name='weight')
            self.cond_layers.append(cond_layer)

            # last one is not necessary
            if i < n_layers - 1:
                res_skip_channels = 2 * n_channels
            else:
                res_skip_channels = n_channels
            res_skip_layer = torch.nn.Conv1d(n_channels, res_skip_channels, 1)
            res_skip_layer = torch.nn.utils.parametrizations.weight_norm(res_skip_layer,
                                                        name='weight')
            self.res_skip_layers.append(res_skip_layer)
//  [python]
def __init__(self, in_channels, mid_channels, num_blocks, mask, init_zeros=False):
        super(CouplingLayer, self).__init__()

        self.mask = mask

        # Build scale and translate network
        if self.mask.type == MaskType.CHANNEL_WISE:
            in_channels //= 2

        # Pavel: reuse Marc's ResNet block?
        self.st_net = ResNet(in_channels, mid_channels, 2 * in_channels,
                             num_blocks=num_blocks, kernel_size=3, padding=1,
                             double_after_norm=(self.mask.type == MaskType.CHECKERBOARD),
                             init_zeros=init_zeros)

        # Learnable scale for s
        self.rescale = nn.utils.weight_norm(Rescale(in_channels))
//  [python]
def __init__(self, in_channels, mid_channels, num_blocks, mask, init_zeros=False):
        super(CouplingLayer, self).__init__()

        self.mask = mask

        # Build scale and translate network
        if self.mask.type == MaskType.CHANNEL_WISE:
            in_channels //= 2

        # Pavel: reuse Marc's ResNet block?
        self.st_net = ResNet(in_channels, mid_channels, 2 * in_channels,
                             num_blocks=num_blocks, kernel_size=3, padding=1,
                             double_after_norm=(self.mask.type == MaskType.CHECKERBOARD),
                             init_zeros=init_zeros)

        # Learnable scale for s
        self.rescale = nn.utils.parametrizations.weight_norm(Rescale(in_channels))
//  [python]
def __init__(self, parameter, condition_dim=1024, hidden_dim=128, max_scale=1):
        super().__init__()
        self.parameter_shape = parameter.shape

        if len(self.parameter_shape) == 2: # condition_dim是从lstm中得到的tensor，然后用linear学习返回到768作为更新的parm_dict
            self.conditioners = torch.nn.Sequential(
                torch.nn.utils.weight_norm(torch.nn.Linear(condition_dim, hidden_dim)),
                torch.nn.Tanh(),
                torch.nn.utils.weight_norm(
                    torch.nn.Linear(
                        hidden_dim, 2 * (parameter.shape[0] + parameter.shape[1]) + 1
                    )
                ),
            )
        elif len(self.parameter_shape) == 1:
            self.conditioners = torch.nn.Sequential(
                torch.nn.utils.weight_norm(torch.nn.Linear(condition_dim, hidden_dim)),
                torch.nn.Tanh(),
                torch.nn.utils.weight_norm(
                    torch.nn.Linear(hidden_dim, 2 * parameter.shape[0] + 1)
                ),
            )
        else:
            raise RuntimeError()

        self.max_scale = max_scale
//  [python]
def __init__(self, parameter, condition_dim=1024, hidden_dim=128, max_scale=1):
        super().__init__()
        self.parameter_shape = parameter.shape

        if len(self.parameter_shape) == 2: # condition_dim是从lstm中得到的tensor，然后用linear学习返回到768作为更新的parm_dict
            self.conditioners = torch.nn.Sequential(
                torch.nn.utils.parametrizations.weight_norm(torch.nn.Linear(condition_dim, hidden_dim)),
                torch.nn.Tanh(),
                torch.nn.utils.parametrizations.weight_norm(
                    torch.nn.Linear(
                        hidden_dim, 2 * (parameter.shape[0] + parameter.shape[1]) + 1
                    )
                ),
            )
        elif len(self.parameter_shape) == 1:
            self.conditioners = torch.nn.Sequential(
                torch.nn.utils.parametrizations.weight_norm(torch.nn.Linear(condition_dim, hidden_dim)),
                torch.nn.Tanh(),
                torch.nn.utils.parametrizations.weight_norm(
                    torch.nn.Linear(hidden_dim, 2 * parameter.shape[0] + 1)
                ),
            )
        else:
            raise RuntimeError()

        self.max_scale = max_scale
//  [python]
def __init__(self, hidden_size, num_conv_pos_embeddings=128, num_conv_pos_embedding_groups=16):
        super().__init__()
        self.conv = nn.Conv1d(
            hidden_size,
            hidden_size,
            kernel_size=num_conv_pos_embeddings,
            padding=num_conv_pos_embeddings // 2,
            groups=num_conv_pos_embedding_groups,
        )
        # Fix weightnorm deepcopy; see: https://github.com/pytorch/pytorch/issues/28594
        self.conv.orig_deepcopy = getattr(Wav2Vec2PositionalConvEmbedding, '__deepcopy__', None)
        self.conv.__deepcopy__ = __deepcopy__.__get__(self.conv, self.conv.__class__)

        if is_deepspeed_zero3_enabled():
            import deepspeed

            with deepspeed.zero.GatheredParameters(self.conv.weight, modifier_rank=0):
                self.conv = nn.utils.weight_norm(self.conv, name="weight", dim=2)
            deepspeed.zero.register_external_parameter(self, self.conv.weight_v)
            deepspeed.zero.register_external_parameter(self, self.conv.weight_g)
        else:
            self.conv = nn.utils.weight_norm(self.conv, name="weight", dim=2)

        self.padding = Wav2Vec2SamePadLayer(num_conv_pos_embeddings)
        self.activation = F.gelu
//  [python]
def __init__(self, hidden_size, num_conv_pos_embeddings=128, num_conv_pos_embedding_groups=16):
        super().__init__()
        self.conv = nn.Conv1d(
            hidden_size,
            hidden_size,
            kernel_size=num_conv_pos_embeddings,
            padding=num_conv_pos_embeddings // 2,
            groups=num_conv_pos_embedding_groups,
        )
        # Fix weightnorm deepcopy; see: https://github.com/pytorch/pytorch/issues/28594
        self.conv.orig_deepcopy = getattr(Wav2Vec2PositionalConvEmbedding, '__deepcopy__', None)
        self.conv.__deepcopy__ = __deepcopy__.__get__(self.conv, self.conv.__class__)

        if is_deepspeed_zero3_enabled():
            import deepspeed

            with deepspeed.zero.GatheredParameters(self.conv.weight, modifier_rank=0):
                self.conv = nn.utils.parametrizations.weight_norm(self.conv, name="weight", dim=2)
            deepspeed.zero.register_external_parameter(self, self.conv.weight_v)
            deepspeed.zero.register_external_parameter(self, self.conv.weight_g)
        else:
            self.conv = nn.utils.parametrizations.weight_norm(self.conv, name="weight", dim=2)

        self.padding = Wav2Vec2SamePadLayer(num_conv_pos_embeddings)
        self.activation = F.gelu
//  [python]
def __init__(self, in_dim, mid_dim, num_layers, mask, init_zeros=False,dropout=False):

        super(CouplingLayerTabular, self).__init__()
        self.mask = mask
        self.layers = [
            nn.Linear(in_dim, mid_dim),
            nn.ReLU(),
            nn.Dropout(.5) if dropout else nn.Sequential(),
            *self._inner_seq(num_layers, mid_dim),
        ]
        last_layer = nn.Linear(mid_dim, in_dim*2)
        if init_zeros:
            nn.init.zeros_(last_layer.weight)
            nn.init.zeros_(last_layer.bias)
        self.layers.append(last_layer)

        self.st_net = nn.Sequential(*self.layers)
        self.rescale = nn.utils.weight_norm(RescaleTabular(in_dim))
//  [python]
def __init__(self, in_dim, mid_dim, num_layers, mask, init_zeros=False,dropout=False):

        super(CouplingLayerTabular, self).__init__()
        self.mask = mask
        self.layers = [
            nn.Linear(in_dim, mid_dim),
            nn.ReLU(),
            nn.Dropout(.5) if dropout else nn.Sequential(),
            *self._inner_seq(num_layers, mid_dim),
        ]
        last_layer = nn.Linear(mid_dim, in_dim*2)
        if init_zeros:
            nn.init.zeros_(last_layer.weight)
            nn.init.zeros_(last_layer.bias)
        self.layers.append(last_layer)

        self.st_net = nn.Sequential(*self.layers)
        self.rescale = nn.utils.parametrizations.weight_norm(RescaleTabular(in_dim))
//  [python]
def __init__(self, args):
        super(WDSR, self).__init__()
        self.args = args
        scale = args.scale[0]
        n_resblocks = args.n_resblocks
        n_feats = args.n_feats
        kernel_size = 3
        act = nn.ReLU(True)
        wn = lambda x: torch.nn.utils.weight_norm(x)
        self.rgb_mean = torch.autograd.Variable(torch.FloatTensor([args.r_mean, args.g_mean, args.b_mean])).view([1, 3, 1, 1])
        head = []
        head.append(wn(nn.Conv2d(args.n_colors, n_feats, 3, padding=3 // 2)))
        body = []
        for i in range(n_resblocks):
            body.append(Block(n_feats, kernel_size, args.block_feats, wn=wn, res_scale=args.res_scale, act=act))
        tail = []
        out_feats = scale * scale * args.n_colors
        tail.append(wn(nn.Conv2d(n_feats, out_feats, 3, padding=3 // 2)))
        skip = []
        skip.append(wn(nn.Conv2d(args.n_colors, out_feats, 5, padding=5 // 2)))
        self.head = nn.Sequential(*head)
        self.body = nn.Sequential(*body)
        self.tail = nn.Sequential(*tail)
        self.skip = nn.Sequential(*skip)
//  [python]
def __init__(self, args):
        super(WDSR, self).__init__()
        self.args = args
        scale = args.scale[0]
        n_resblocks = args.n_resblocks
        n_feats = args.n_feats
        kernel_size = 3
        act = nn.ReLU(True)
        wn = lambda x: torch.nn.utils.parametrizations.weight_norm(x)
        self.rgb_mean = torch.autograd.Variable(torch.FloatTensor([args.r_mean, args.g_mean, args.b_mean])).view([1, 3, 1, 1])
        head = []
        head.append(wn(nn.Conv2d(args.n_colors, n_feats, 3, padding=3 // 2)))
        body = []
        for i in range(n_resblocks):
            body.append(Block(n_feats, kernel_size, args.block_feats, wn=wn, res_scale=args.res_scale, act=act))
        tail = []
        out_feats = scale * scale * args.n_colors
        tail.append(wn(nn.Conv2d(n_feats, out_feats, 3, padding=3 // 2)))
        skip = []
        skip.append(wn(nn.Conv2d(args.n_colors, out_feats, 5, padding=5 // 2)))
        self.head = nn.Sequential(*head)
        self.body = nn.Sequential(*body)
        self.tail = nn.Sequential(*tail)
        self.skip = nn.Sequential(*skip)
//  [python]
def __init__(self, args):
        super(AwsrnModel, self).__init__(args)
        # hyper-params
        self.args = args
        self.bam = args.bam
        self.device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
        scale = args.scale
        n_resblocks = args.n_resblocks
        n_feats = args.n_feats
        kernel_size = 3
        res_scale = args.res_scale
        n_awru = args.n_awru
        act = nn.ReLU(True)
        # wn = lambda x: x
        wn = lambda x: torch.nn.utils.weight_norm(x)

        self.rgb_mean = torch.autograd.Variable(torch.FloatTensor(args.rgb_mean)).view([1, 3, 1, 1])

        # define head module
        # head = HEAD(args, n_feats, kernel_size, wn)
        head = []
        head.append(
            wn(nn.Conv2d(args.n_colors, n_feats, 3, padding=3 // 2)))

        # define body module
        body = []
        for i in range(n_resblocks):
            body.append(
                LFB(n_feats, kernel_size, args.block_feats, n_awru, wn=wn, res_scale=res_scale, act=act))

        # define tail module
        out_feats = scale * scale * args.n_colors
        tail = AWMS(args, scale, n_feats, kernel_size, wn)

        skip = []
        skip.append(
            wn(nn.Conv2d(args.n_colors, out_feats, 3, padding=3 // 2))
        )
        skip.append(nn.PixelShuffle(scale))

        # make object members
        self.head = nn.Sequential(*head)
        self.body = nn.Sequential(*body)
        self.tail = tail
        self.skip = nn.Sequential(*skip)
        if self.bam:
            self.attention = BamBlock(args.block_feats // 4, reduction=8)
//  [python]
def __init__(self, args):
        super(AwsrnModel, self).__init__(args)
        # hyper-params
        self.args = args
        self.bam = args.bam
        self.device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
        scale = args.scale
        n_resblocks = args.n_resblocks
        n_feats = args.n_feats
        kernel_size = 3
        res_scale = args.res_scale
        n_awru = args.n_awru
        act = nn.ReLU(True)
        # wn = lambda x: x
        wn = lambda x: torch.nn.utils.parametrizations.weight_norm(x)

        self.rgb_mean = torch.autograd.Variable(torch.FloatTensor(args.rgb_mean)).view([1, 3, 1, 1])

        # define head module
        # head = HEAD(args, n_feats, kernel_size, wn)
        head = []
        head.append(
            wn(nn.Conv2d(args.n_colors, n_feats, 3, padding=3 // 2)))

        # define body module
        body = []
        for i in range(n_resblocks):
            body.append(
                LFB(n_feats, kernel_size, args.block_feats, n_awru, wn=wn, res_scale=res_scale, act=act))

        # define tail module
        out_feats = scale * scale * args.n_colors
        tail = AWMS(args, scale, n_feats, kernel_size, wn)

        skip = []
        skip.append(
            wn(nn.Conv2d(args.n_colors, out_feats, 3, padding=3 // 2))
        )
        skip.append(nn.PixelShuffle(scale))

        # make object members
        self.head = nn.Sequential(*head)
        self.body = nn.Sequential(*body)
        self.tail = tail
        self.skip = nn.Sequential(*skip)
        if self.bam:
            self.attention = BamBlock(args.block_feats // 4, reduction=8)
//  [python]
def __init__(self, n_feat, n_resblocks, da=False):
        super(ResidualGroup, self).__init__()
        kernel_size = 3
        res_scale = 1
        reduction = 16

        conv = common.default_conv
        wn = lambda x: torch.nn.utils.weight_norm(x)

        modules_body = []
        modules_body = [
            RCAB(
                conv, n_feat, kernel_size, reduction, wn=wn, bias=True,
                bn=False, act=nn.ReLU(True), res_scale=res_scale, da=da) \
            for _ in range(n_resblocks)]
        modules_body.append(wn(conv(n_feat, n_feat, kernel_size)))
        self.body = nn.Sequential(*modules_body)
//  [python]
def __init__(self, n_feat, n_resblocks, da=False):
        super(ResidualGroup, self).__init__()
        kernel_size = 3
        res_scale = 1
        reduction = 16

        conv = common.default_conv
        wn = lambda x: torch.nn.utils.parametrizations.weight_norm(x)

        modules_body = []
        modules_body = [
            RCAB(
                conv, n_feat, kernel_size, reduction, wn=wn, bias=True,
                bn=False, act=nn.ReLU(True), res_scale=res_scale, da=da) \
            for _ in range(n_resblocks)]
        modules_body.append(wn(conv(n_feat, n_feat, kernel_size)))
        self.body = nn.Sequential(*modules_body)
//  [python]
def __init__(self, n_feat, n_resblocks, da=False, idx=0):
        super(LRSCResidualGroup, self).__init__()
        kernel_size = 3
        res_scale = 1
        reduction = 16

        conv = common.default_conv
        wn = lambda x: torch.nn.utils.weight_norm(x)

        modules_head = [wn(conv(n_feat*(idx+1), n_feat, 1, bias=True))] if idx > 0 else []
        modules_body = [
            LRSCRCAB(
                conv, n_feat, kernel_size, reduction, wn=wn, bias=True,
                bn=False, act=nn.ReLU(True), res_scale=res_scale, da=da, idx=i) \
            for i in range(n_resblocks)]
        modules_body.append(wn(conv(n_feat*(n_resblocks+1), n_feat, kernel_size)))
        self.head = nn.Sequential(*modules_head)
        self.body = nn.Sequential(*modules_body)
//  [python]
def __init__(self, n_feat, n_resblocks, da=False, idx=0):
        super(LRSCResidualGroup, self).__init__()
        kernel_size = 3
        res_scale = 1
        reduction = 16

        conv = common.default_conv
        wn = lambda x: torch.nn.utils.parametrizations.weight_norm(x)

        modules_head = [wn(conv(n_feat*(idx+1), n_feat, 1, bias=True))] if idx > 0 else []
        modules_body = [
            LRSCRCAB(
                conv, n_feat, kernel_size, reduction, wn=wn, bias=True,
                bn=False, act=nn.ReLU(True), res_scale=res_scale, da=da, idx=i) \
            for i in range(n_resblocks)]
        modules_body.append(wn(conv(n_feat*(n_resblocks+1), n_feat, kernel_size)))
        self.head = nn.Sequential(*modules_head)
        self.body = nn.Sequential(*modules_body)
//  [python]
def __init__(self, nf=64, idx=0):
        super(LRSCWideActResBlock, self).__init__()
        self.res_scale = 1

        expand = 6
        linear = 0.8
        kernel_size = 3
        wn = lambda x: torch.nn.utils.weight_norm(x)
        act=nn.ReLU(True)
        head = [wn(nn.Conv2d(nf*(idx+1), nf, 1, bias=True))] if idx > 0 else []

        body = []
        body.append(
            wn(nn.Conv2d(nf, nf*expand, 1, padding=1//2)))
        body.append(act)
        body.append(
            wn(nn.Conv2d(nf*expand, int(nf*linear), 1, padding=1//2)))
        body.append(
            wn(nn.Conv2d(int(nf*linear), nf, kernel_size, padding=kernel_size//2)))

        self.head = nn.Sequential(*head)
        self.body = nn.Sequential(*body)
//  [python]
def __init__(self, nf=64, idx=0):
        super(LRSCWideActResBlock, self).__init__()
        self.res_scale = 1

        expand = 6
        linear = 0.8
        kernel_size = 3
        wn = lambda x: torch.nn.utils.parametrizations.weight_norm(x)
        act=nn.ReLU(True)
        head = [wn(nn.Conv2d(nf*(idx+1), nf, 1, bias=True))] if idx > 0 else []

        body = []
        body.append(
            wn(nn.Conv2d(nf, nf*expand, 1, padding=1//2)))
        body.append(act)
        body.append(
            wn(nn.Conv2d(nf*expand, int(nf*linear), 1, padding=1//2)))
        body.append(
            wn(nn.Conv2d(int(nf*linear), nf, kernel_size, padding=kernel_size//2)))

        self.head = nn.Sequential(*head)
        self.body = nn.Sequential(*body)
//  [python]
def __init__(self, n_feat, n_resblocks, da=False, idx=0):
        super(LRSCPSResidualGroup, self).__init__()
        kernel_size = 3
        res_scale = 1
        reduction = 16

        conv = PSConv2d
        wn = lambda x: torch.nn.utils.weight_norm(x)

        modules_head = [wn(nn.Conv2d(n_feat*(idx+1), n_feat, 1, 1, 0, bias=True))] if idx > 0 else []
        modules_body = [
            LRSCRCAB(
                conv, n_feat, kernel_size, reduction, wn=wn, bias=True,
                bn=False, act=nn.ReLU(True), res_scale=res_scale, da=da, idx=i) \
            for i in range(n_resblocks)]
        modules_tail = [wn(conv(n_feat*(n_resblocks+1), n_feat, kernel_size))]
        self.head = nn.Sequential(*modules_head)
        self.body = nn.Sequential(*modules_body)
        self.tail = nn.Sequential(*modules_tail)
//  [python]
def __init__(self, n_feat, n_resblocks, da=False, idx=0):
        super(LRSCPSResidualGroup, self).__init__()
        kernel_size = 3
        res_scale = 1
        reduction = 16

        conv = PSConv2d
        wn = lambda x: torch.nn.utils.parametrizations.weight_norm(x)

        modules_head = [wn(nn.Conv2d(n_feat*(idx+1), n_feat, 1, 1, 0, bias=True))] if idx > 0 else []
        modules_body = [
            LRSCRCAB(
                conv, n_feat, kernel_size, reduction, wn=wn, bias=True,
                bn=False, act=nn.ReLU(True), res_scale=res_scale, da=da, idx=i) \
            for i in range(n_resblocks)]
        modules_tail = [wn(conv(n_feat*(n_resblocks+1), n_feat, kernel_size))]
        self.head = nn.Sequential(*modules_head)
        self.body = nn.Sequential(*modules_body)
        self.tail = nn.Sequential(*modules_tail)
//  [python]
def __init__(self, n_feat, n_resblocks, da=False, idx=0):
        super(LRSCPyResidualGroup, self).__init__()
        kernel_size = 3
        res_scale = 1
        reduction = 16

        conv = PyConv2d
        wn = lambda x: torch.nn.utils.weight_norm(x)

        modules_head = [wn(nn.Conv2d(n_feat*(idx+1), n_feat, 1, 1, 0, bias=True))] if idx > 0 else []
        modules_body = [
            LRSCPYRCAB(
                conv, n_feat, kernel_size, reduction, wn=wn, bias=True,
                bn=False, act=nn.ReLU(True), res_scale=res_scale, da=da, idx=i) \
            for i in range(n_resblocks)]
        modules_tail = [wn(nn.Conv2d(n_feat*(n_resblocks+1), n_feat, 1))]
        self.head = nn.Sequential(*modules_head)
        self.body = nn.Sequential(*modules_body)
        self.tail = nn.Sequential(*modules_tail)
//  [python]
def __init__(self, n_feat, n_resblocks, da=False, idx=0):
        super(LRSCPyResidualGroup, self).__init__()
        kernel_size = 3
        res_scale = 1
        reduction = 16

        conv = PyConv2d
        wn = lambda x: torch.nn.utils.parametrizations.weight_norm(x)

        modules_head = [wn(nn.Conv2d(n_feat*(idx+1), n_feat, 1, 1, 0, bias=True))] if idx > 0 else []
        modules_body = [
            LRSCPYRCAB(
                conv, n_feat, kernel_size, reduction, wn=wn, bias=True,
                bn=False, act=nn.ReLU(True), res_scale=res_scale, da=da, idx=i) \
            for i in range(n_resblocks)]
        modules_tail = [wn(nn.Conv2d(n_feat*(n_resblocks+1), n_feat, 1))]
        self.head = nn.Sequential(*modules_head)
        self.body = nn.Sequential(*modules_body)
        self.tail = nn.Sequential(*modules_tail)
//  [python]
def __init__(self, nf, n_resblocks, idx=0):
        super(LRSCPyWideActResGroup, self).__init__()
        kernel_size = 3

        conv = PyConv2d
        wn = lambda x: torch.nn.utils.weight_norm(x)

        modules_head = [wn(nn.Conv2d(nf*(idx+1), nf, 1, 1, 0, bias=True))] if idx > 0 else []
        modules_body = [
            LRSCPyWideActResBlock(nf=nf, idx=i) for i in range(n_resblocks)]
        modules_tail = [wn(nn.Conv2d(nf*(n_resblocks+1), nf, 1))]
        self.head = nn.Sequential(*modules_head)
        self.body = nn.Sequential(*modules_body)
        self.tail = nn.Sequential(*modules_tail)
//  [python]
def __init__(self, nf, n_resblocks, idx=0):
        super(LRSCPyWideActResGroup, self).__init__()
        kernel_size = 3

        conv = PyConv2d
        wn = lambda x: torch.nn.utils.parametrizations.weight_norm(x)

        modules_head = [wn(nn.Conv2d(nf*(idx+1), nf, 1, 1, 0, bias=True))] if idx > 0 else []
        modules_body = [
            LRSCPyWideActResBlock(nf=nf, idx=i) for i in range(n_resblocks)]
        modules_tail = [wn(nn.Conv2d(nf*(n_resblocks+1), nf, 1))]
        self.head = nn.Sequential(*modules_head)
        self.body = nn.Sequential(*modules_body)
        self.tail = nn.Sequential(*modules_tail)
//  [python]
def __init__(self, nf, n_resblocks, idx=0):
        super(LRSCWideActResGroup, self).__init__()
        kernel_size = 3

        conv = PyConv2d
        wn = lambda x: torch.nn.utils.weight_norm(x)

        modules_head = [wn(nn.Conv2d(nf*(idx+1), nf, 1, 1, 0, bias=True))] if idx > 0 else []
        modules_body = [
            LRSCWideActResBlock(nf=nf, idx=i) for i in range(n_resblocks)]
        modules_tail = [wn(nn.Conv2d(nf*(n_resblocks+1), nf, 1))]
        self.head = nn.Sequential(*modules_head)
        self.body = nn.Sequential(*modules_body)
        self.tail = nn.Sequential(*modules_tail)
//  [python]
def __init__(self, nf, n_resblocks, idx=0):
        super(LRSCWideActResGroup, self).__init__()
        kernel_size = 3

        conv = PyConv2d
        wn = lambda x: torch.nn.utils.parametrizations.weight_norm(x)

        modules_head = [wn(nn.Conv2d(nf*(idx+1), nf, 1, 1, 0, bias=True))] if idx > 0 else []
        modules_body = [
            LRSCWideActResBlock(nf=nf, idx=i) for i in range(n_resblocks)]
        modules_tail = [wn(nn.Conv2d(nf*(n_resblocks+1), nf, 1))]
        self.head = nn.Sequential(*modules_head)
        self.body = nn.Sequential(*modules_body)
        self.tail = nn.Sequential(*modules_tail)
//  [python]
def __init__(self, nf=64, idx=0):
        super(LRSCPyWideActResBlock, self).__init__()
        self.res_scale = 1

        expand = 6
        linear = 0.75
        kernel_size = 3
        wn = lambda x: torch.nn.utils.weight_norm(x)
        act=nn.ReLU(True)
        head = [wn(nn.Conv2d(nf*(idx+1), nf, 1, bias=True))] if idx > 0 else []

        body = []
        body.append(
            wn(nn.Conv2d(nf, nf*expand, 1, padding=1//2)))
        body.append(act)
        body.append(
            wn(nn.Conv2d(nf*expand, int(nf*linear), 1, padding=1//2)))
        body.append(
            PyConv2d(in_channels=int(nf*linear),
                out_channels=[nf//4, nf//4, nf//2],
                pyconv_kernels=[3, 5, 7],
                pyconv_groups=[1, 4, 8]))

        self.head = nn.Sequential(*head)
        self.body = nn.Sequential(*body)
//  [python]
def __init__(self, nf=64, idx=0):
        super(LRSCPyWideActResBlock, self).__init__()
        self.res_scale = 1

        expand = 6
        linear = 0.75
        kernel_size = 3
        wn = lambda x: torch.nn.utils.parametrizations.weight_norm(x)
        act=nn.ReLU(True)
        head = [wn(nn.Conv2d(nf*(idx+1), nf, 1, bias=True))] if idx > 0 else []

        body = []
        body.append(
            wn(nn.Conv2d(nf, nf*expand, 1, padding=1//2)))
        body.append(act)
        body.append(
            wn(nn.Conv2d(nf*expand, int(nf*linear), 1, padding=1//2)))
        body.append(
            PyConv2d(in_channels=int(nf*linear),
                out_channels=[nf//4, nf//4, nf//2],
                pyconv_kernels=[3, 5, 7],
                pyconv_groups=[1, 4, 8]))

        self.head = nn.Sequential(*head)
        self.body = nn.Sequential(*body)
//  [python]
def __init__(self, n_feat, n_resblocks, da=False):
        super(PyResidualGroup, self).__init__()
        kernel_size = 3
        res_scale = 1
        reduction = 16

        conv = PyConv2d
        wn = lambda x: torch.nn.utils.weight_norm(x)

        modules_body = []
        modules_body = [
            PYRCAB(
                conv, n_feat, kernel_size, reduction, wn=wn, bias=True,
                bn=False, act=nn.ReLU(True), res_scale=res_scale, da=da) \
            for _ in range(n_resblocks)]
        modules_body.append(
            PyConv2d(in_channels=n_feat,
                out_channels=[n_feat//4, n_feat//4, n_feat//2],
                pyconv_kernels=[3, 5, 7],
                pyconv_groups=[1, 4, 8]))
        self.body = nn.Sequential(*modules_body)
//  [python]
def __init__(self, n_feat, n_resblocks, da=False):
        super(PyResidualGroup, self).__init__()
        kernel_size = 3
        res_scale = 1
        reduction = 16

        conv = PyConv2d
        wn = lambda x: torch.nn.utils.parametrizations.weight_norm(x)

        modules_body = []
        modules_body = [
            PYRCAB(
                conv, n_feat, kernel_size, reduction, wn=wn, bias=True,
                bn=False, act=nn.ReLU(True), res_scale=res_scale, da=da) \
            for _ in range(n_resblocks)]
        modules_body.append(
            PyConv2d(in_channels=n_feat,
                out_channels=[n_feat//4, n_feat//4, n_feat//2],
                pyconv_kernels=[3, 5, 7],
                pyconv_groups=[1, 4, 8]))
        self.body = nn.Sequential(*modules_body)
//  [python]
def __init__(self, nf=64):
        super(WideActResBlock, self).__init__()
        self.res_scale = 1
        body = []
        expand = 6
        linear = 0.8
        kernel_size = 3
        wn = lambda x: torch.nn.utils.weight_norm(x)
        act=nn.ReLU(True)

        body.append(
            wn(nn.Conv2d(nf, nf*expand, 1, padding=1//2)))
        body.append(act)
        body.append(
            wn(nn.Conv2d(nf*expand, int(nf*linear), 1, padding=1//2)))
        body.append(
            wn(nn.Conv2d(int(nf*linear), nf, kernel_size, padding=kernel_size//2)))

        self.body = nn.Sequential(*body)
//  [python]
def __init__(self, nf=64):
        super(WideActResBlock, self).__init__()
        self.res_scale = 1
        body = []
        expand = 6
        linear = 0.8
        kernel_size = 3
        wn = lambda x: torch.nn.utils.parametrizations.weight_norm(x)
        act=nn.ReLU(True)

        body.append(
            wn(nn.Conv2d(nf, nf*expand, 1, padding=1//2)))
        body.append(act)
        body.append(
            wn(nn.Conv2d(nf*expand, int(nf*linear), 1, padding=1//2)))
        body.append(
            wn(nn.Conv2d(int(nf*linear), nf, kernel_size, padding=kernel_size//2)))

        self.body = nn.Sequential(*body)
//  [python]
def __init__(self, channels, kernel_size=3, dilation=(1, 3)):
        super(ResBlock3, self).__init__()
        self.convs = nn.ModuleList([
            weight_norm(Conv1d(channels, channels, kernel_size, 1, dilation=dilation[0],
                               padding=get_padding(kernel_size, dilation[0])))
        ])
        self.convs.apply(init_weights)
//  [python]
def __init__(self, channels, kernel_size=3, dilation=(1, 3)):
        super(ResBlock3, self).__init__()
        self.convs = nn.ModuleList([
            nn.utils.parametrizations.weight_norm(Conv1d(channels, channels, kernel_size, 1, dilation=dilation[0],
                               padding=get_padding(kernel_size, dilation[0])))
        ])
        self.convs.apply(init_weights)
//  [python]
def __init__(self, nf=64):
        super(PSWideActResBlock, self).__init__()
        self.res_scale = 1
        body = []
        expand = 6
        linear = 0.75
        kernel_size = 3
        wn = lambda x: torch.nn.utils.weight_norm(x)
        act=nn.ReLU(True)

        body.append(
            wn(nn.Conv2d(nf, nf*expand, 1, padding=1//2)))
        body.append(act)
        body.append(
            wn(nn.Conv2d(nf*expand, int(nf*linear), 1, padding=1//2)))
        body.append(
            wn(PSConv2d(int(nf*linear), nf, kernel_size, padding=kernel_size//2)))

        self.body = nn.Sequential(*body)
//  [python]
def __init__(self, nf=64):
        super(PSWideActResBlock, self).__init__()
        self.res_scale = 1
        body = []
        expand = 6
        linear = 0.75
        kernel_size = 3
        wn = lambda x: torch.nn.utils.parametrizations.weight_norm(x)
        act=nn.ReLU(True)

        body.append(
            wn(nn.Conv2d(nf, nf*expand, 1, padding=1//2)))
        body.append(act)
        body.append(
            wn(nn.Conv2d(nf*expand, int(nf*linear), 1, padding=1//2)))
        body.append(
            wn(PSConv2d(int(nf*linear), nf, kernel_size, padding=kernel_size//2)))

        self.body = nn.Sequential(*body)
//  [python]
def __init__(self, nf=64):
        super(PyWideActResBlock, self).__init__()
        self.res_scale = 1
        body = []
        expand = 6
        linear = 0.75
        kernel_size = 3
        wn = lambda x: torch.nn.utils.weight_norm(x)
        act=nn.ReLU(True)
        expand_nf = nf*expand
        linear_nf = int(nf * linear)

        body.append(
            wn(nn.Conv2d(nf, nf*expand, 1, padding=1//2)))
        body.append(act)
        body.append(
            wn(nn.Conv2d(nf*expand, int(nf*linear), 1, padding=1//2)))
        body.append(
            PyConv2d(in_channels=linear_nf,
                out_channels=[nf//4, nf//4, nf//2],
                pyconv_kernels=[3, 5, 7],
                pyconv_groups=[1, 4, 8]))

        self.body = nn.Sequential(*body)
//  [python]
def __init__(self, nf=64):
        super(PyWideActResBlock, self).__init__()
        self.res_scale = 1
        body = []
        expand = 6
        linear = 0.75
        kernel_size = 3
        wn = lambda x: torch.nn.utils.parametrizations.weight_norm(x)
        act=nn.ReLU(True)
        expand_nf = nf*expand
        linear_nf = int(nf * linear)

        body.append(
            wn(nn.Conv2d(nf, nf*expand, 1, padding=1//2)))
        body.append(act)
        body.append(
            wn(nn.Conv2d(nf*expand, int(nf*linear), 1, padding=1//2)))
        body.append(
            PyConv2d(in_channels=linear_nf,
                out_channels=[nf//4, nf//4, nf//2],
                pyconv_kernels=[3, 5, 7],
                pyconv_groups=[1, 4, 8]))

        self.body = nn.Sequential(*body)
//  [python]
def enable_weight_norm(self):
        """Enables weight normalization on synapse."""
        self = torch.nn.utils.weight_norm(self, name='weight')
        self.weight_norm_enabled = True
//  [python]
def enable_weight_norm(self):
        """Enables weight normalization on synapse."""
        self = torch.nn.utils.parametrizations.weight_norm(self, name='weight')
        self.weight_norm_enabled = True
//  [python]
def __init__(self,
            d_model, L, ff,
            diffusion_step_embed_dim_out=512,
            unconditional=False,
            mel_upsample=[16,16],
        ):
        super().__init__()
        self.d_model = d_model

        # the layer-specific fc for diffusion step embedding
        self.fc_t = nn.Linear(diffusion_step_embed_dim_out, self.d_model)

        self.layer = S4(d_model, l_max=L, bidirectional=True)
        self.ff = FF(d_model, ff)

        self.norm1 = TransposedLN(d_model)
        self.norm2 = TransposedLN(d_model)

        self.unconditional = unconditional
        if not self.unconditional:
            # add mel spectrogram upsampler and conditioner conv1x1 layer
            self.upsample_conv2d = torch.nn.ModuleList()
            for s in mel_upsample:
                conv_trans2d = torch.nn.ConvTranspose2d(1, 1, (3, 2 * s), padding=(1, s // 2), stride=(1, s))
                conv_trans2d = torch.nn.utils.weight_norm(conv_trans2d)
                torch.nn.init.kaiming_normal_(conv_trans2d.weight)
                self.upsample_conv2d.append(conv_trans2d)
            self.mel_conv = Conv(80, self.d_model, kernel_size=1)
//  [python]
def __init__(self,
            d_model, L, ff,
            diffusion_step_embed_dim_out=512,
            unconditional=False,
            mel_upsample=[16,16],
        ):
        super().__init__()
        self.d_model = d_model

        # the layer-specific fc for diffusion step embedding
        self.fc_t = nn.Linear(diffusion_step_embed_dim_out, self.d_model)

        self.layer = S4(d_model, l_max=L, bidirectional=True)
        self.ff = FF(d_model, ff)

        self.norm1 = TransposedLN(d_model)
        self.norm2 = TransposedLN(d_model)

        self.unconditional = unconditional
        if not self.unconditional:
            # add mel spectrogram upsampler and conditioner conv1x1 layer
            self.upsample_conv2d = torch.nn.ModuleList()
            for s in mel_upsample:
                conv_trans2d = torch.nn.ConvTranspose2d(1, 1, (3, 2 * s), padding=(1, s // 2), stride=(1, s))
                conv_trans2d = torch.nn.utils.parametrizations.weight_norm(conv_trans2d)
                torch.nn.init.kaiming_normal_(conv_trans2d.weight)
                self.upsample_conv2d.append(conv_trans2d)
            self.mel_conv = Conv(80, self.d_model, kernel_size=1)
//  [python]
def __init__(self, in_channels, out_channels, kernel_size, dilation, final=False):
        super(DilatedBlock, self).__init__()

        padding = (kernel_size - 1) * dilation

        self.conv_block1 = nn.Sequential(
            utils.weight_norm(nn.Conv1d(in_channels, out_channels, kernel_size,
                                        padding=padding, dilation=dilation)),
            Chomp1d(padding),
            nn.LeakyReLU()
        )

        self.conv_block2 = nn.Sequential(
            utils.weight_norm(nn.Conv1d(out_channels, out_channels, kernel_size,
                                        padding=padding, dilation=dilation)),
            Chomp1d(padding),
            nn.LeakyReLU()
        )

        # whether apply residual connection
        self.upordownsample = torch.nn.Conv1d(
            in_channels, out_channels, 1
        ) if in_channels != out_channels else None

        self.relu = torch.nn.LeakyReLU() if final else None
//  [python]
def __init__(self, in_channels, out_channels, kernel_size, dilation, final=False):
        super(DilatedBlock, self).__init__()

        padding = (kernel_size - 1) * dilation

        self.conv_block1 = nn.Sequential(
            nn.utils.parametrizations.weight_norm(nn.Conv1d(in_channels, out_channels, kernel_size,
                                        padding=padding, dilation=dilation)),
            Chomp1d(padding),
            nn.LeakyReLU()
        )

        self.conv_block2 = nn.Sequential(
            nn.utils.parametrizations.weight_norm(nn.Conv1d(out_channels, out_channels, kernel_size,
                                        padding=padding, dilation=dilation)),
            Chomp1d(padding),
            nn.LeakyReLU()
        )

        # whether apply residual connection
        self.upordownsample = torch.nn.Conv1d(
            in_channels, out_channels, 1
        ) if in_channels != out_channels else None

        self.relu = torch.nn.LeakyReLU() if final else None
//  [python]
def __init__(
        self,
        d_in,
        d_out,
        width,
        depth,
        weight_norm=True,
        skip_layer=[],
    ):
        super().__init__()

        dims = [d_in] + [width] * depth + [d_out]
        self.num_layers = len(dims)

        self.skip_layer = skip_layer

        for l in range(0, self.num_layers - 1):

            if l in self.skip_layer:
                lin = torch.nn.Linear(dims[l] + dims[0], dims[l+1])
            else:
                lin = torch.nn.Linear(dims[l], dims[l+1])

            if weight_norm:
                lin = torch.nn.utils.weight_norm(lin)
            else:
                torch.nn.init.xavier_uniform_(lin.weight)
                torch.nn.init.zeros_(lin.bias)


            setattr(self, "lin" + str(l), lin)

        self.activation = torch.nn.LeakyReLU()
//  [python]
def __init__(
        self,
        d_in,
        d_out,
        width,
        depth,
        weight_norm=True,
        skip_layer=[],
    ):
        super().__init__()

        dims = [d_in] + [width] * depth + [d_out]
        self.num_layers = len(dims)

        self.skip_layer = skip_layer

        for l in range(0, self.num_layers - 1):

            if l in self.skip_layer:
                lin = torch.nn.Linear(dims[l] + dims[0], dims[l+1])
            else:
                lin = torch.nn.Linear(dims[l], dims[l+1])

            if weight_norm:
                lin = torch.nn.utils.parametrizations.weight_norm(lin)
            else:
                torch.nn.init.xavier_uniform_(lin.weight)
                torch.nn.init.zeros_(lin.bias)


            setattr(self, "lin" + str(l), lin)

        self.activation = torch.nn.LeakyReLU()
//  [python]
def __init__(self, in_channels, hidden_channels=512):
        super(BaseFrequenceDiscriminator, self).__init__()

        self.discriminator = nn.ModuleList()
        self.discriminator += [
            nn.Sequential(
                nn.ReflectionPad2d((1, 1, 1, 1)),
                nn.utils.weight_norm(nn.Conv2d(
                    in_channels, hidden_channels // 32,
                    kernel_size=(3, 3), stride=(1, 1)))
            ),
            nn.Sequential(
                nn.LeakyReLU(0.2, True),
                nn.ReflectionPad2d((1, 1, 1, 1)),
                nn.utils.weight_norm(nn.Conv2d(
                    hidden_channels // 32, hidden_channels // 16,
                    kernel_size=(3, 3), stride=(2, 2)))
            ),
            nn.Sequential(
                nn.LeakyReLU(0.2, True),
                nn.ReflectionPad2d((1, 1, 1, 1)),
                nn.utils.weight_norm(nn.Conv2d(
                    hidden_channels // 16, hidden_channels // 8,
                    kernel_size=(3, 3), stride=(1, 1)))
            ),
            nn.Sequential(
                nn.LeakyReLU(0.2, True),
                nn.ReflectionPad2d((1, 1, 1, 1)),
                nn.utils.weight_norm(nn.Conv2d(
                    hidden_channels // 8, hidden_channels // 4,
                    kernel_size=(3, 3), stride=(2, 2)))
            ),
            nn.Sequential(
                nn.LeakyReLU(0.2, True),
                nn.ReflectionPad2d((1, 1, 1, 1)),
                nn.utils.weight_norm(nn.Conv2d(
                    hidden_channels // 4, hidden_channels // 2,
                    kernel_size=(3, 3), stride=(1, 1)))
            ),
            nn.Sequential(
                nn.LeakyReLU(0.2, True),
                nn.ReflectionPad2d((1, 1, 1, 1)),
                nn.utils.weight_norm(nn.Conv2d(
                    hidden_channels // 2, hidden_channels,
                    kernel_size=(3, 3), stride=(2, 2)))
            ),
            nn.Sequential(
                nn.LeakyReLU(0.2, True),
                nn.ReflectionPad2d((1, 1, 1, 1)),
                nn.utils.weight_norm(nn.Conv2d(
                    hidden_channels, 1,
                    kernel_size=(3, 3), stride=(1, 1)))
            )
        ]
//  [python]
def __init__(self, in_channels, hidden_channels=512):
        super(BaseFrequenceDiscriminator, self).__init__()

        self.discriminator = nn.ModuleList()
        self.discriminator += [
            nn.Sequential(
                nn.ReflectionPad2d((1, 1, 1, 1)),
                nn.utils.parametrizations.weight_norm(nn.Conv2d(
                    in_channels, hidden_channels // 32,
                    kernel_size=(3, 3), stride=(1, 1)))
            ),
            nn.Sequential(
                nn.LeakyReLU(0.2, True),
                nn.ReflectionPad2d((1, 1, 1, 1)),
                nn.utils.parametrizations.weight_norm(nn.Conv2d(
                    hidden_channels // 32, hidden_channels // 16,
                    kernel_size=(3, 3), stride=(2, 2)))
            ),
            nn.Sequential(
                nn.LeakyReLU(0.2, True),
                nn.ReflectionPad2d((1, 1, 1, 1)),
                nn.utils.parametrizations.weight_norm(nn.Conv2d(
                    hidden_channels // 16, hidden_channels // 8,
                    kernel_size=(3, 3), stride=(1, 1)))
            ),
            nn.Sequential(
                nn.LeakyReLU(0.2, True),
                nn.ReflectionPad2d((1, 1, 1, 1)),
                nn.utils.parametrizations.weight_norm(nn.Conv2d(
                    hidden_channels // 8, hidden_channels // 4,
                    kernel_size=(3, 3), stride=(2, 2)))
            ),
            nn.Sequential(
                nn.LeakyReLU(0.2, True),
                nn.ReflectionPad2d((1, 1, 1, 1)),
                nn.utils.parametrizations.weight_norm(nn.Conv2d(
                    hidden_channels // 4, hidden_channels // 2,
                    kernel_size=(3, 3), stride=(1, 1)))
            ),
            nn.Sequential(
                nn.LeakyReLU(0.2, True),
                nn.ReflectionPad2d((1, 1, 1, 1)),
                nn.utils.parametrizations.weight_norm(nn.Conv2d(
                    hidden_channels // 2, hidden_channels,
                    kernel_size=(3, 3), stride=(2, 2)))
            ),
            nn.Sequential(
                nn.LeakyReLU(0.2, True),
                nn.ReflectionPad2d((1, 1, 1, 1)),
                nn.utils.parametrizations.weight_norm(nn.Conv2d(
                    hidden_channels, 1,
                    kernel_size=(3, 3), stride=(1, 1)))
            )
        ]