jiahuimbzuai/CoQuIR huggingface dataset:
//  [python]
def LinearActivation(
    d_input, d_output, bias=True,
    zero_bias_init=False,
    transposed=False,
    initializer=None,
    activation=None,
    activate=False,  # Apply activation as part of this module
    weight_norm=False,
    **kwargs,
):
    """ Returns a linear nn.Module with control over axes order, initialization, and activation """

    # Construct core module
    linear_cls = TransposedLinear if transposed else nn.Linear
    if activation == 'glu':
        d_output *= 2
    linear = linear_cls(d_input, d_output, bias=bias, **kwargs)

    # Initialize weight
    if initializer is not None:
        get_initializer(initializer, activation)(linear.weight)

    # Initialize bias
    if bias and zero_bias_init:
        nn.init.zeros_(linear.bias)

    # Weight norm
    if weight_norm:
        linear = nn.utils.parametrizations.weight_norm(linear)

    if activate and activation is not None:
        activation = Activation(activation, dim=-2 if transposed else -1)
        linear = nn.Sequential(linear, activation)
    return linear
//  [python]
def __init__(self, in_channel, cin_channel, res_channel, n_height, n_flow, n_layer, layers_per_dilation_h_cycle):
        super().__init__()
        self.in_channel = in_channel
        self.cin_channel = cin_channel
        self.res_channel = res_channel
        self.n_height = n_height
        self.n_flow = n_flow
        self.n_layer = n_layer

        self.layers_per_dilation_h_cycle = layers_per_dilation_h_cycle

        # major change: shared flow weights
        self.flow = Flow(self.in_channel, self.cin_channel, filter_size=self.res_channel,
                         num_layer=self.n_layer, num_height=self.n_height,
                         layers_per_dilation_h_cycle=self.layers_per_dilation_h_cycle)

        self.upsample_conv = nn.ModuleList()
        for s in [16, 16]:
            convt = nn.ConvTranspose2d(1, 1, (3, 2 * s), padding=(1, s // 2), stride=(1, s))
            convt = nn.utils.weight_norm(convt)
            nn.init.kaiming_normal_(convt.weight)
            self.upsample_conv.append(convt)
            self.upsample_conv.append(nn.LeakyReLU(0.4))

        self.upsample_conv_kernel_size = (2 * s) ** 2
        self.upsample_conv_stride = s ** 2
//  [python]
def __init__(self, in_channel, cin_channel, res_channel, n_height, n_flow, n_layer, layers_per_dilation_h_cycle):
        super().__init__()
        self.in_channel = in_channel
        self.cin_channel = cin_channel
        self.res_channel = res_channel
        self.n_height = n_height
        self.n_flow = n_flow
        self.n_layer = n_layer

        self.layers_per_dilation_h_cycle = layers_per_dilation_h_cycle

        # major change: shared flow weights
        self.flow = Flow(self.in_channel, self.cin_channel, filter_size=self.res_channel,
                         num_layer=self.n_layer, num_height=self.n_height,
                         layers_per_dilation_h_cycle=self.layers_per_dilation_h_cycle)

        self.upsample_conv = nn.ModuleList()
        for s in [16, 16]:
            convt = nn.ConvTranspose2d(1, 1, (3, 2 * s), padding=(1, s // 2), stride=(1, s))
            convt = nn.utils.parametrizations.weight_norm(convt)
            nn.init.kaiming_normal_(convt.weight)
            self.upsample_conv.append(convt)
            self.upsample_conv.append(nn.LeakyReLU(0.4))

        self.upsample_conv_kernel_size = (2 * s) ** 2
        self.upsample_conv_stride = s ** 2
//  [python]
def _gen_deconv(self, in_ch, out_ch, strides=(2, 1), k=4, gain=math.sqrt(2), p=1, use_weight_norm=False):
        conv = nn.ConvTranspose2d(
            in_ch, out_ch, kernel_size=(k, 3), stride=strides, padding_mode='zeros', padding=(p, 1), dilation=1
        )

        if use_weight_norm:
            conv = torch.nn.utils.weight_norm(conv, name='weight')

        w = conv.weight
        k = w.size(1) * w.size(2) * w.size(3)
        conv.weight.data.normal_(0.0, gain / math.sqrt(k))
        nn.init.constant_(conv.bias, 0.01)
        return conv
//  [python]
def _gen_deconv(self, in_ch, out_ch, strides=(2, 1), k=4, gain=math.sqrt(2), p=1, use_weight_norm=False):
        conv = nn.ConvTranspose2d(
            in_ch, out_ch, kernel_size=(k, 3), stride=strides, padding_mode='zeros', padding=(p, 1), dilation=1
        )

        if use_weight_norm:
            conv = torch.nn.utils.parametrizations.weight_norm(conv, name='weight')

        w = conv.weight
        k = w.size(1) * w.size(2) * w.size(3)
        conv.weight.data.normal_(0.0, gain / math.sqrt(k))
        nn.init.constant_(conv.bias, 0.01)
        return conv
//  [python]
def __init__(self):
        super().__init__()
        self.conv_transpose = torch.nn.utils.weight_norm(torch.nn.ConvTranspose2d(1, 1, kernel_size=(1, 1), stride=1))
//  [python]
def __init__(self):
        super().__init__()
        self.conv_transpose = torch.nn.utils.parametrizations.weight_norm(torch.nn.ConvTranspose2d(1, 1, kernel_size=(1, 1), stride=1))
//  [python]
def __init__(
        self,
        in_channels: int,
        out_channels: int,
        kernel_size: int,
        dilation: int,
    ):
        """
        Args:
            in_channels: The number of input channels.
            out_channels: The number of output channels.
            kernel_size: The kernel size to use for the convolution.
            dilation: The dilation parameter to use for the causal convolution.
        """
        super().__init__()

        conv = torch.nn.Conv1d(
            in_channels,
            out_channels,
            kernel_size=kernel_size,
            dilation=dilation,
        )
        self.padding = (kernel_size - 1) * dilation
        self.normalized_conv = torch.nn.utils.weight_norm(conv)
        self.activation = torch.nn.LeakyReLU()
//  [python]
def __init__(
        self,
        in_channels: int,
        out_channels: int,
        kernel_size: int,
        dilation: int,
    ):
        """
        Args:
            in_channels: The number of input channels.
            out_channels: The number of output channels.
            kernel_size: The kernel size to use for the convolution.
            dilation: The dilation parameter to use for the causal convolution.
        """
        super().__init__()

        conv = torch.nn.Conv1d(
            in_channels,
            out_channels,
            kernel_size=kernel_size,
            dilation=dilation,
        )
        self.padding = (kernel_size - 1) * dilation
        self.normalized_conv = torch.nn.utils.parametrizations.weight_norm(conv)
        self.activation = torch.nn.LeakyReLU()
//  [python]
def apply_ema(model, ema_model, decay, patch_conv_wn=False):
    if not decay:
        return

    if patch_conv_wn:
        torch.nn.utils.remove_weight_norm(model.encoder.pos_conv[0])

    sd = getattr(model, 'module', model).state_dict()

    for k, v in ema_model.state_dict().items():
        v.copy_(decay * v + (1 - decay) * sd[k])

    if patch_conv_wn:
        torch.nn.utils.weight_norm(
            model.encoder.pos_conv[0], name="weight", dim=2)
//  [python]
def apply_ema(model, ema_model, decay, patch_conv_wn=False):
    if not decay:
        return

    if patch_conv_wn:
        torch.nn.utils.remove_weight_norm(model.encoder.pos_conv[0])

    sd = getattr(model, 'module', model).state_dict()

    for k, v in ema_model.state_dict().items():
        v.copy_(decay * v + (1 - decay) * sd[k])

    if patch_conv_wn:
        torch.nn.utils.parametrizations.weight_norm(
            model.encoder.pos_conv[0], name="weight", dim=2)
//  [python]
def __init__(self, h):
        super().__init__()
        self.h = h

        self.num_kernels = len(h["resblock_kernel_sizes"])
        self.num_upsamples = len(h["upsample_rates"])
        self.f0_upsamp = torch.nn.Upsample(scale_factor=np.prod(h["upsample_rates"]))
        self.m_source = SourceModuleHnNSF(
            sampling_rate=h["sampling_rate"], harmonic_num=8
        )
        self.noise_convs = nn.ModuleList()
        self.conv_pre = weight_norm(
            Conv1d(h["inter_channels"], h["upsample_initial_channel"], 7, 1, padding=3)
        )
        resblock = ResBlock1 if h["resblock"] == "1" else ResBlock2
        self.ups = nn.ModuleList()
        for i, (u, k) in enumerate(
            zip(h["upsample_rates"], h["upsample_kernel_sizes"])
        ):
            c_cur = h["upsample_initial_channel"] // (2 ** (i + 1))
            self.ups.append(
                weight_norm(
                    ConvTranspose1d(
                        h["upsample_initial_channel"] // (2**i),
                        h["upsample_initial_channel"] // (2 ** (i + 1)),
                        k,
                        u,
                        padding=(k - u) // 2,
                    )
                )
            )
            if i + 1 < len(h["upsample_rates"]):  #
                stride_f0 = np.prod(h["upsample_rates"][i + 1 :])
                self.noise_convs.append(
                    Conv1d(
                        1,
                        c_cur,
                        kernel_size=stride_f0 * 2,
                        stride=stride_f0,
                        padding=stride_f0 // 2,
                    )
                )
            else:
                self.noise_convs.append(Conv1d(1, c_cur, kernel_size=1))
        self.resblocks = nn.ModuleList()
        for i in range(len(self.ups)):
            ch = h["upsample_initial_channel"] // (2 ** (i + 1))
            for j, (k, d) in enumerate(
                zip(h["resblock_kernel_sizes"], h["resblock_dilation_sizes"])
            ):
                self.resblocks.append(resblock(ch, k, d))

        self.conv_post = weight_norm(Conv1d(ch, 1, 7, 1, padding=3))
        self.ups.apply(init_weights)
        self.conv_post.apply(init_weights)
        self.cond = nn.Conv1d(h["gin_channels"], h["upsample_initial_channel"], 1)
//  [python]
def __init__(self, h):
        super().__init__()
        self.h = h

        self.num_kernels = len(h["resblock_kernel_sizes"])
        self.num_upsamples = len(h["upsample_rates"])
        self.f0_upsamp = torch.nn.Upsample(scale_factor=np.prod(h["upsample_rates"]))
        self.m_source = SourceModuleHnNSF(
            sampling_rate=h["sampling_rate"], harmonic_num=8
        )
        self.noise_convs = nn.ModuleList()
        self.conv_pre = torch.nn.utils.parametrizations.weight_norm(
            Conv1d(h["inter_channels"], h["upsample_initial_channel"], 7, 1, padding=3)
        )
        resblock = ResBlock1 if h["resblock"] == "1" else ResBlock2
        self.ups = nn.ModuleList()
        for i, (u, k) in enumerate(
            zip(h["upsample_rates"], h["upsample_kernel_sizes"])
        ):
            c_cur = h["upsample_initial_channel"] // (2 ** (i + 1))
            self.ups.append(
                torch.nn.utils.parametrizations.weight_norm(
                    ConvTranspose1d(
                        h["upsample_initial_channel"] // (2**i),
                        h["upsample_initial_channel"] // (2 ** (i + 1)),
                        k,
                        u,
                        padding=(k - u) // 2,
                    )
                )
            )
            if i + 1 < len(h["upsample_rates"]):  #
                stride_f0 = np.prod(h["upsample_rates"][i + 1 :])
                self.noise_convs.append(
                    Conv1d(
                        1,
                        c_cur,
                        kernel_size=stride_f0 * 2,
                        stride=stride_f0,
                        padding=stride_f0 // 2,
                    )
                )
            else:
                self.noise_convs.append(Conv1d(1, c_cur, kernel_size=1))
        self.resblocks = nn.ModuleList()
        for i in range(len(self.ups)):
            ch = h["upsample_initial_channel"] // (2 ** (i + 1))
            for j, (k, d) in enumerate(
                zip(h["resblock_kernel_sizes"], h["resblock_dilation_sizes"])
            ):
                self.resblocks.append(resblock(ch, k, d))

        self.conv_post = torch.nn.utils.parametrizations.weight_norm(Conv1d(ch, 1, 7, 1, padding=3))
        self.ups.apply(init_weights)
        self.conv_post.apply(init_weights)
        self.cond = nn.Conv1d(h["gin_channels"], h["upsample_initial_channel"], 1)
//  [python]
def __init__(self):
        super(Affine_Coupling_Layer, self).__init__()

        self.layer_Dict = torch.nn.ModuleDict()

        self.layer_Dict['Start'] = torch.nn.utils.weight_norm(Conv1d(
            in_channels= hp.Sound.Mel_Dim * hp.Decoder.Num_Squeeze // 2,
            out_channels= hp.Decoder.Affine_Coupling.Calc_Channels,
            kernel_size= 1,
            w_init_gain= 'linear'
            ))
        self.layer_Dict['WaveNet'] = WaveNet()
        self.layer_Dict['End'] = Conv1d(
            in_channels= hp.Decoder.Affine_Coupling.Calc_Channels,
            out_channels= hp.Sound.Mel_Dim * hp.Decoder.Num_Squeeze,
            kernel_size= 1,
            w_init_gain= 'zero'
            )
//  [python]
def __init__(self):
        super(Affine_Coupling_Layer, self).__init__()

        self.layer_Dict = torch.nn.ModuleDict()

        self.layer_Dict['Start'] = torch.nn.utils.parametrizations.weight_norm(Conv1d(
            in_channels= hp.Sound.Mel_Dim * hp.Decoder.Num_Squeeze // 2,
            out_channels= hp.Decoder.Affine_Coupling.Calc_Channels,
            kernel_size= 1,
            w_init_gain= 'linear'
            ))
        self.layer_Dict['WaveNet'] = WaveNet()
        self.layer_Dict['End'] = Conv1d(
            in_channels= hp.Decoder.Affine_Coupling.Calc_Channels,
            out_channels= hp.Sound.Mel_Dim * hp.Decoder.Num_Squeeze,
            kernel_size= 1,
            w_init_gain= 'zero'
            )
//  [python]
def __init__(self, in_channels, out_channels, kernel_size=3, stride=1, groups=1, dilation=1, bias=True):
        super(DilatedCausalConv1d, self).__init__()
        self.kernel_size = kernel_size
        self.dilation = dilation
        self.stride = stride
        self.conv = weight_norm(nn.Conv1d(in_channels, out_channels, kernel_size, stride=stride, groups=groups, dilation=dilation, bias=bias))
//  [python]
def __init__(self, in_channels, out_channels, kernel_size=3, stride=1, groups=1, dilation=1, bias=True):
        super(DilatedCausalConv1d, self).__init__()
        self.kernel_size = kernel_size
        self.dilation = dilation
        self.stride = stride
        self.conv = torch.nn.utils.parametrizations.weight_norm(nn.Conv1d(in_channels, out_channels, kernel_size, stride=stride, groups=groups, dilation=dilation, bias=bias))
//  [python]
def __init__(self, in_channels, out_channels, kernel_rate=3, stride=1, groups=1):
        super(CausalConvTranspose1d, self).__init__()
        kernel_size = kernel_rate * stride
        self.trim_size = (kernel_rate - 1) * stride
        self.conv = weight_norm(nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, groups=groups))
//  [python]
def __init__(self, in_channels, out_channels, kernel_rate=3, stride=1, groups=1):
        super(CausalConvTranspose1d, self).__init__()
        kernel_size = kernel_rate * stride
        self.trim_size = (kernel_rate - 1) * stride
        self.conv = nn.utils.parametrizations.weight_norm(nn.ConvTranspose1d(in_channels, out_channels, kernel_size, stride=stride, groups=groups))
//  [python]
def __init__(
        self,
        in_dim: int,
        out_dim: int,
        text_hidden_dim: int,
        img_hidden_dim: int,
        pretrained_image: np.ndarray = None,
        pretrained_text: np.ndarray = None,
    ):
        super(LogitClassifier, self).__init__()

        self.f_o_text = nn.utils.weight_norm(nn.Linear(in_dim, text_hidden_dim), dim=-1)
        self.f_o_image = nn.utils.weight_norm(nn.Linear(in_dim, img_hidden_dim), dim=-1)
        self.linear_text = nn.Linear(text_hidden_dim, out_dim)
        self.linear_image = nn.Linear(img_hidden_dim, out_dim)

        if pretrained_image is not None and pretrained_text is not None:
            self.linear_text.weight.data.copy_(torch.from_numpy(pretrained_text))

        if pretrained_image is not None and pretrained_image is not None:
            self.linear_image.weight.data.copy_(torch.from_numpy(pretrained_image))
//  [python]
def __init__(
        self,
        in_dim: int,
        out_dim: int,
        text_hidden_dim: int,
        img_hidden_dim: int,
        pretrained_image: np.ndarray = None,
        pretrained_text: np.ndarray = None,
    ):
        super(LogitClassifier, self).__init__()

        self.f_o_text = nn.utils.parametrizations.weight_norm(nn.Linear(in_dim, text_hidden_dim), dim=-1)
        self.f_o_image = nn.utils.parametrizations.weight_norm(nn.Linear(in_dim, img_hidden_dim), dim=-1)
        self.linear_text = nn.Linear(text_hidden_dim, out_dim)
        self.linear_image = nn.Linear(img_hidden_dim, out_dim)

        if pretrained_image is not None and pretrained_text is not None:
            self.linear_text.weight.data.copy_(torch.from_numpy(pretrained_text))

        if pretrained_image is not None and pretrained_image is not None:
            self.linear_image.weight.data.copy_(torch.from_numpy(pretrained_image))
//  [python]
def __init__(self, in_channels, out_channels, info_channels, r):
        super().__init__()
        self.in_channels = in_channels
        self.out_channels = out_channels
        self.info_channels = info_channels
        self.r = r
        self.main_fc = weight_norm(nn.Conv1d(in_channels, out_channels, 1))
        self.adapter_in = nn.Conv1d(info_channels, in_channels * r, 1)
        self.adapter_out = nn.Conv1d(info_channels, out_channels * r, 1)
        nn.init.normal_(self.adapter_in.weight.data, 0, 0.01)
        nn.init.constant_(self.adapter_out.weight.data, 1e-6)
        self.adapter_in = weight_norm(self.adapter_in)
        self.adapter_out = weight_norm(self.adapter_out)
        self.speaker_fixed = False
//  [python]
def __init__(self, in_channels, out_channels, info_channels, r):
        super().__init__()
        self.in_channels = in_channels
        self.out_channels = out_channels
        self.info_channels = info_channels
        self.r = r
        self.main_fc = nn.utils.parametrizations.weight_norm(nn.Conv1d(in_channels, out_channels, 1))
        self.adapter_in = nn.Conv1d(info_channels, in_channels * r, 1)
        self.adapter_out = nn.Conv1d(info_channels, out_channels * r, 1)
        nn.init.normal_(self.adapter_in.weight.data, 0, 0.01)
        nn.init.constant_(self.adapter_out.weight.data, 1e-6)
        self.adapter_in = nn.utils.parametrizations.weight_norm(self.adapter_in)
        self.adapter_out = nn.utils.parametrizations.weight_norm(self.adapter_out)
        self.speaker_fixed = False
//  [python]
def __init__(self, args):
        super(MODEL, self).__init__()
        # hyper-params
        self.args = args
        scale = 2
        n_resblocks = args.n_resblocks
        n_feats = args.n_feats
        kernel_size = 3
        act = nn.ReLU(True)
        # wn = lambda x: x
        wn = lambda x: torch.nn.utils.weight_norm(x)

#       Batch's Size: batch_size x channel x H x W
        self.rgb_mean = torch.autograd.Variable(
            torch.FloatTensor([args.r_mean, args.g_mean, args.b_mean])).view([1, 3, 1, 1])

        # define head module
        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(
                Block(n_feats, kernel_size, act=act, res_scale=args.res_scale, wn=wn))

        # define tail module
        tail = []
        out_feats = scale*scale*args.n_colors
        tail.append(
            wn(nn.Conv2d(n_feats, out_feats, 3, padding=3//2)))
        tail.append(nn.PixelShuffle(scale))

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

        # make object members
        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(MODEL, self).__init__()
        # hyper-params
        self.args = args
        scale = 2
        n_resblocks = args.n_resblocks
        n_feats = args.n_feats
        kernel_size = 3
        act = nn.ReLU(True)
        # wn = lambda x: x
        wn = lambda x: torch.nn.utils.parametrizations.weight_norm(x)

#       Batch's Size: batch_size x channel x H x W
        self.rgb_mean = torch.autograd.Variable(
            torch.FloatTensor([args.r_mean, args.g_mean, args.b_mean])).view([1, 3, 1, 1])

        # define head module
        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(
                Block(n_feats, kernel_size, act=act, res_scale=args.res_scale, wn=wn))

        # define tail module
        tail = []
        out_feats = scale*scale*args.n_colors
        tail.append(
            wn(nn.Conv2d(n_feats, out_feats, 3, padding=3//2)))
        tail.append(nn.PixelShuffle(scale))

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

        # make object members
        self.head = nn.Sequential(*head)
        self.body = nn.Sequential(*body)
        self.tail = nn.Sequential(*tail)
        self.skip = nn.Sequential(*skip)
//  [python]
def __init__(self, channels, groups, kernel_size, num_layers, eps=1e-6):
        super(SnakeFilter, self).__init__()
        self.eps = eps
        self.num_layers = num_layers
        inner_channels = channels * groups
        self.init_conv = DilatedCausalConv1d(1, inner_channels, kernel_size)
        self.dconvs = torch.nn.ModuleList()
        self.pconvs = torch.nn.ModuleList()
        self.post_conv = DilatedCausalConv1d(inner_channels+1, 1, kernel_size, bias=False)

        for i in range(self.num_layers):
            self.dconvs.append(DilatedCausalConv1d(inner_channels, inner_channels, kernel_size, stride=1, groups=inner_channels, dilation=kernel_size ** (i + 1)))
            self.pconvs.append(weight_norm(Conv1d(inner_channels, inner_channels, 1, groups=groups)))
        self.snake_alpha = torch.nn.Parameter(torch.zeros(inner_channels), requires_grad=True)
        self.snake_beta = torch.nn.Parameter(torch.zeros(inner_channels), requires_grad=True)
//  [python]
def __init__(self, channels, groups, kernel_size, num_layers, eps=1e-6):
        super(SnakeFilter, self).__init__()
        self.eps = eps
        self.num_layers = num_layers
        inner_channels = channels * groups
        self.init_conv = DilatedCausalConv1d(1, inner_channels, kernel_size)
        self.dconvs = torch.nn.ModuleList()
        self.pconvs = torch.nn.ModuleList()
        self.post_conv = DilatedCausalConv1d(inner_channels+1, 1, kernel_size, bias=False)

        for i in range(self.num_layers):
            self.dconvs.append(DilatedCausalConv1d(inner_channels, inner_channels, kernel_size, stride=1, groups=inner_channels, dilation=kernel_size ** (i + 1)))
            self.pconvs.append(torch.nn.utils.parametrizations.weight_norm(Conv1d(inner_channels, inner_channels, 1, groups=groups)))
        self.snake_alpha = torch.nn.Parameter(torch.zeros(inner_channels), requires_grad=True)
        self.snake_beta = torch.nn.Parameter(torch.zeros(inner_channels), requires_grad=True)
//  [python]
def test_weight_norm_state_dict_compat(self):
        m = nn.Linear(4, 5)
        m = torch.nn.utils.weight_norm(m)
        old_dict = m.state_dict()

        m2 = nn.Linear(4, 5)
        m2 = torch.nn.utils.parametrizations.weight_norm(m2)
        m2.load_state_dict(old_dict)

        input1 = torch.randn(3, 4)
        self.assertEqual(m(input1), m2(input1))
//  [python]
def test_weight_norm_state_dict_compat(self):
        m = nn.Linear(4, 5)
        m = torch.nn.utils.parametrizations.weight_norm(m)
        old_dict = m.state_dict()

        m2 = nn.Linear(4, 5)
        m2 = torch.nn.utils.parametrizations.weight_norm(m2)
        m2.load_state_dict(old_dict)

        input1 = torch.randn(3, 4)
        self.assertEqual(m(input1), m2(input1))
//  [python]
def __init__(self):
        super(WaveNet, self).__init__()
        self.layer_Dict = torch.nn.ModuleDict()

        for index in range(hp.Decoder.Affine_Coupling.WaveNet.Num_Layers):
            self.layer_Dict['In_{}'.format(index)] = torch.nn.utils.weight_norm(Conv1d(
                in_channels= hp.Decoder.Affine_Coupling.Calc_Channels,
                out_channels= hp.Decoder.Affine_Coupling.Calc_Channels * 2,
                kernel_size= hp.Decoder.Affine_Coupling.WaveNet.Kernel_Size,
                padding= (hp.Decoder.Affine_Coupling.WaveNet.Kernel_Size - 1) // 2,
                w_init_gain= ['tanh', 'sigmoid']
                ))
            self.layer_Dict['Res_Skip_{}'.format(index)] = torch.nn.utils.weight_norm(Conv1d(
                in_channels= hp.Decoder.Affine_Coupling.Calc_Channels,
                out_channels= hp.Decoder.Affine_Coupling.Calc_Channels * (2 if index < hp.Decoder.Affine_Coupling.WaveNet.Num_Layers - 1 else 1),
                kernel_size= 1,
                w_init_gain= 'linear'
                ))

            if hp.Mode.upper() in ['SE', 'GR']:
                self.layer_Dict['Speaker_{}'.format(index)] = torch.nn.utils.weight_norm(Conv1d(
                    in_channels= hp.Speaker_Embedding.Embedding_Size,
                    out_channels= hp.Decoder.Affine_Coupling.Calc_Channels * 2,
                    kernel_size= 1,
                    w_init_gain= ['tanh', 'sigmoid']
                    ))
            if hp.Mode.upper() in ['PE', 'GR']:
                self.layer_Dict['Prosody_{}'.format(index)] = torch.nn.utils.weight_norm(Conv1d(
                    in_channels= hp.Prosody_Encoder.Size,
                    out_channels= hp.Decoder.Affine_Coupling.Calc_Channels * 2,
                    kernel_size= 1,
                    w_init_gain= ['tanh', 'sigmoid']
                    ))
            if hp.Mode.upper() == 'GR':
                self.layer_Dict['Pitch_{}'.format(index)] = torch.nn.utils.weight_norm(Conv1d(
                    in_channels= hp.Decoder.Num_Squeeze,
                    out_channels= hp.Decoder.Affine_Coupling.Calc_Channels * 2,
                    kernel_size= 1,
                    w_init_gain= ['tanh', 'sigmoid']
                    ))

        self.layer_Dict['Dropout'] = torch.nn.Dropout(
            p= hp.Decoder.Affine_Coupling.WaveNet.Dropout_Rate
            )
//  [python]
def __init__(self):
        super(WaveNet, self).__init__()
        self.layer_Dict = torch.nn.ModuleDict()

        for index in range(hp.Decoder.Affine_Coupling.WaveNet.Num_Layers):
            self.layer_Dict['In_{}'.format(index)] = torch.nn.utils.parametrizations.weight_norm(Conv1d(
                in_channels= hp.Decoder.Affine_Coupling.Calc_Channels,
                out_channels= hp.Decoder.Affine_Coupling.Calc_Channels * 2,
                kernel_size= hp.Decoder.Affine_Coupling.WaveNet.Kernel_Size,
                padding= (hp.Decoder.Affine_Coupling.WaveNet.Kernel_Size - 1) // 2,
                w_init_gain= ['tanh', 'sigmoid']
                ))
            self.layer_Dict['Res_Skip_{}'.format(index)] = torch.nn.utils.parametrizations.weight_norm(Conv1d(
                in_channels= hp.Decoder.Affine_Coupling.Calc_Channels,
                out_channels= hp.Decoder.Affine_Coupling.Calc_Channels * (2 if index < hp.Decoder.Affine_Coupling.WaveNet.Num_Layers - 1 else 1),
                kernel_size= 1,
                w_init_gain= 'linear'
                ))

            if hp.Mode.upper() in ['SE', 'GR']:
                self.layer_Dict['Speaker_{}'.format(index)] = torch.nn.utils.parametrizations.weight_norm(Conv1d(
                    in_channels= hp.Speaker_Embedding.Embedding_Size,
                    out_channels= hp.Decoder.Affine_Coupling.Calc_Channels * 2,
                    kernel_size= 1,
                    w_init_gain= ['tanh', 'sigmoid']
                    ))
            if hp.Mode.upper() in ['PE', 'GR']:
                self.layer_Dict['Prosody_{}'.format(index)] = torch.nn.utils.parametrizations.weight_norm(Conv1d(
                    in_channels= hp.Prosody_Encoder.Size,
                    out_channels= hp.Decoder.Affine_Coupling.Calc_Channels * 2,
                    kernel_size= 1,
                    w_init_gain= ['tanh', 'sigmoid']
                    ))
            if hp.Mode.upper() == 'GR':
                self.layer_Dict['Pitch_{}'.format(index)] = torch.nn.utils.parametrizations.weight_norm(Conv1d(
                    in_channels= hp.Decoder.Num_Squeeze,
                    out_channels= hp.Decoder.Affine_Coupling.Calc_Channels * 2,
                    kernel_size= 1,
                    w_init_gain= ['tanh', 'sigmoid']
                    ))

        self.layer_Dict['Dropout'] = torch.nn.Dropout(
            p= hp.Decoder.Affine_Coupling.WaveNet.Dropout_Rate
            )
//  [python]
def __init__(self, args):
        super(MODEL, self).__init__()
        # hyper-params
        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: x
        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])

        # define head module
        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(
                Block(n_feats, kernel_size, args.block_feats, wn=wn, res_scale=args.res_scale, act=act))

        # define tail module
        tail = []
        out_feats = scale*scale*args.n_colors
        tail.append(
            wn(nn.Conv2d(n_feats, out_feats, 3, padding=3//2)))
        tail.append(nn.PixelShuffle(scale))

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

        # make object members
        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(MODEL, self).__init__()
        # hyper-params
        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: x
        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])

        # define head module
        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(
                Block(n_feats, kernel_size, args.block_feats, wn=wn, res_scale=args.res_scale, act=act))

        # define tail module
        tail = []
        out_feats = scale*scale*args.n_colors
        tail.append(
            wn(nn.Conv2d(n_feats, out_feats, 3, padding=3//2)))
        tail.append(nn.PixelShuffle(scale))

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

        # make object members
        self.head = nn.Sequential(*head)
        self.body = nn.Sequential(*body)
        self.tail = nn.Sequential(*tail)
        self.skip = nn.Sequential(*skip)
//  [python]
def __init__(self, h, channels, kernel_size=3, dilation=(1, 3, 5, 7)):
        super(ResBlock1, self).__init__()
        self.h = h
        self.convs1 = nn.ModuleList([
            weight_norm(Conv1d(channels, channels, kernel_size, 1, dilation=dilation[0],
                               padding=get_padding(kernel_size, dilation[0]))),
            weight_norm(Conv1d(channels, channels, kernel_size, 1, dilation=dilation[1],
                               padding=get_padding(kernel_size, dilation[1]))),
            weight_norm(Conv1d(channels, channels, kernel_size, 1, dilation=dilation[2],
                               padding=get_padding(kernel_size, dilation[2]))),
            weight_norm(Conv1d(channels, channels, kernel_size, 1, dilation=dilation[3],
                               padding=get_padding(kernel_size, dilation[3])))
        ])
        self.convs1.apply(init_weights)

        self.convs2 = nn.ModuleList([
            weight_norm(Conv1d(channels, channels, kernel_size, 1, dilation=1,
                               padding=get_padding(kernel_size, 1))),
            weight_norm(Conv1d(channels, channels, kernel_size, 1, dilation=1,
                               padding=get_padding(kernel_size, 1))),
            weight_norm(Conv1d(channels, channels, kernel_size, 1, dilation=1,
                               padding=get_padding(kernel_size, 1))),
            weight_norm(Conv1d(channels, channels, kernel_size, 1, dilation=1,
                               padding=get_padding(kernel_size, 1)))
        ])
        self.convs2.apply(init_weights)
//  [python]
def __init__(self, h, channels, kernel_size=3, dilation=(1, 3, 5, 7)):
        super(ResBlock1, self).__init__()
        self.h = h
        self.convs1 = nn.ModuleList([
            parametrizations.weight_norm(Conv1d(channels, channels, kernel_size, 1, dilation=dilation[0],
                               padding=get_padding(kernel_size, dilation[0]))),
            parametrizations.weight_norm(Conv1d(channels, channels, kernel_size, 1, dilation=dilation[1],
                               padding=get_padding(kernel_size, dilation[1]))),
            parametrizations.weight_norm(Conv1d(channels, channels, kernel_size, 1, dilation=dilation[2],
                               padding=get_padding(kernel_size, dilation[2]))),
            parametrizations.weight_norm(Conv1d(channels, channels, kernel_size, 1, dilation=dilation[3],
                               padding=get_padding(kernel_size, dilation[3])))
        ])
        self.convs1.apply(init_weights)

        self.convs2 = nn.ModuleList([
            parametrizations.weight_norm(Conv1d(channels, channels, kernel_size, 1, dilation=1,
                               padding=get_padding(kernel_size, 1))),
            parametrizations.weight_norm(Conv1d(channels, channels, kernel_size, 1, dilation=1,
                               padding=get_padding(kernel_size, 1))),
            parametrizations.weight_norm(Conv1d(channels, channels, kernel_size, 1, dilation=1,
                               padding=get_padding(kernel_size, 1))),
            parametrizations.weight_norm(Conv1d(channels, channels, kernel_size, 1, dilation=1,
                               padding=get_padding(kernel_size, 1)))
        ])
        self.convs2.apply(init_weights)
//  [python]
def __init__(self, in_channel, out_channel):
        super(DistLinear, self).__init__()
        self.fc = nn.Linear(in_channel, out_channel, bias=False)
        self.class_wise_learnable_norm = True
        if self.class_wise_learnable_norm:
            weight_norm(self.fc, 'weight', dim=0)
        if out_channel <= 200:
            self.scale_factor = 2
        else:
            self.scale_factor = 10
//  [python]
def __init__(self, in_channel, out_channel):
        super(DistLinear, self).__init__()
        self.fc = nn.Linear(in_channel, out_channel, bias=False)
        self.class_wise_learnable_norm = True
        if self.class_wise_learnable_norm:
            nn.utils.parametrizations.weight_norm(self.fc, 'weight', dim=0)
        if out_channel <= 200:
            self.scale_factor = 2
        else:
            self.scale_factor = 10
//  [python]
def weight_norm_modules(module, name="weight", dim=0):
    if isinstance(module, Depthwise_Separable_Conv1D) or isinstance(
            module, Depthwise_Separable_TransposeConv1D
    ):
        module.weight_norm()
        return module
    else:
        return weight_norm(module, name, dim)
//  [python]
def weight_norm_modules(module, name="weight", dim=0):
    if isinstance(module, Depthwise_Separable_Conv1D) or isinstance(
            module, Depthwise_Separable_TransposeConv1D
    ):
        module.weight_norm()
        return module
    else:
        return torch.nn.utils.parametrizations.weight_norm(module, name, dim)
//  [python]
def __init__(self, args):
        super(AWSRN, self).__init__()
        # hyper-params
        self.args = args
        scale = args.scale
        n_resblocks = args.n_resblocks_awsrn
        n_feats = args.n_feats_awsrn
        kernel_size = 3
        res_scale = args.res_scale_awsrn
        n_awru = args.n_awru_awsrn
        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(
            [0.4488, 0.4371, 0.4040])).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_awsrn, 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)
//  [python]
def __init__(self, args):
        super(AWSRN, self).__init__()
        # hyper-params
        self.args = args
        scale = args.scale
        n_resblocks = args.n_resblocks_awsrn
        n_feats = args.n_feats_awsrn
        kernel_size = 3
        res_scale = args.res_scale_awsrn
        n_awru = args.n_awru_awsrn
        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(
            [0.4488, 0.4371, 0.4040])).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_awsrn, 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)
//  [python]
def __init__(self, args):
        super(AWSRN_blanced_attention, self).__init__()
        # hyper-params
        self.args = args
        scale = args.scale
        n_resblocks = args.n_resblocks_awsrn
        n_feats = args.n_feats_awsrn
        kernel_size = 3
        res_scale = args.res_scale_awsrn
        n_awru = args.n_awru_awsrn
        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([0.4488, 0.4371, 0.4040])).view([1, 3, 1, 1])

        # define head module
        # head = HEAD(args, n_feats, kernel_size, wn)
        head = []
        head.append(
            wn(nn.Conv2d(3, 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_awsrn, n_awru, wn=wn, res_scale=res_scale, act=act))

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

        skip = []
        skip.append(
            wn(nn.Conv2d(3, 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)
        self.attention=BlancedAttention(args.block_feats_awsrn//4,reduction=8)
//  [python]
def __init__(self, args):
        super(AWSRN_blanced_attention, self).__init__()
        # hyper-params
        self.args = args
        scale = args.scale
        n_resblocks = args.n_resblocks_awsrn
        n_feats = args.n_feats_awsrn
        kernel_size = 3
        res_scale = args.res_scale_awsrn
        n_awru = args.n_awru_awsrn
        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([0.4488, 0.4371, 0.4040])).view([1, 3, 1, 1])

        # define head module
        # head = HEAD(args, n_feats, kernel_size, wn)
        head = []
        head.append(
            wn(nn.Conv2d(3, 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_awsrn, n_awru, wn=wn, res_scale=res_scale, act=act))

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

        skip = []
        skip.append(
            wn(nn.Conv2d(3, 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)
        self.attention=BlancedAttention(args.block_feats_awsrn//4,reduction=8)
//  [python]
def __init__(self, h, top_k=4):
        super(FreGAN, self).__init__()
        self.h = h

        self.num_kernels = len(h.resblock_kernel_sizes)
        self.num_upsamples = len(h.upsample_rates)
        self.upsample_rates = h.upsample_rates
        self.up_kernels = h.upsample_kernel_sizes
        self.cond_level = self.num_upsamples - top_k
        self.conv_pre = weight_norm(Conv1d(80, h.upsample_initial_channel, 7, 1, padding=3))
        resblock = ResBlock1 if h.resblock == '1' else ResBlock2

        self.ups = nn.ModuleList()
        self.cond_up = nn.ModuleList()
        self.res_output = nn.ModuleList()
        upsample_ = 1
        kr = 80

        for i, (u, k) in enumerate(zip(self.upsample_rates, self.up_kernels)):
#            self.ups.append(weight_norm(
 #               ConvTranspose1d(h.upsample_initial_channel // (2 ** i), h.upsample_initial_channel // (2 ** (i + 1)),
 #                               k, u, padding=(k - u) // 2)))
            self.ups.append(weight_norm(ConvTranspose1d(h.upsample_initial_channel//(2**i),
                            h.upsample_initial_channel//(2**(i+1)),
                            k, u, padding=(u//2 + u%2), output_padding=u%2)))

            if i > (self.num_upsamples - top_k):
                self.res_output.append(
                    nn.Sequential(
                        nn.Upsample(scale_factor=u, mode='nearest'),
                        weight_norm(nn.Conv1d(h.upsample_initial_channel // (2 ** i),
                                              h.upsample_initial_channel // (2 ** (i + 1)), 1))
                    )
                )
            if i >= (self.num_upsamples - top_k):
                self.cond_up.append(
                    weight_norm(
                        ConvTranspose1d(kr, h.upsample_initial_channel // (2 ** i),
                                        self.up_kernels[i - 1], self.upsample_rates[i - 1],
                                        padding=(self.upsample_rates[i-1]//2+self.upsample_rates[i-1]%2), output_padding=self.upsample_rates[i-1]%2))
                )
                kr = h.upsample_initial_channel // (2 ** i)

            upsample_ *= u

        self.resblocks = nn.ModuleList()
        for i in range(len(self.ups)):
            ch = h.upsample_initial_channel // (2 ** (i + 1))
            for j, (k, d) in enumerate(zip(h.resblock_kernel_sizes, h.resblock_dilation_sizes)):
                self.resblocks.append(resblock(h, ch, k, d))

        self.conv_post = weight_norm(Conv1d(ch, 1, 7, 1, padding=3))
        self.ups.apply(init_weights)
        self.conv_post.apply(init_weights)
        self.cond_up.apply(init_weights)
        self.res_output.apply(init_weights)
//  [python]
def __init__(self, h, top_k=4):
        super(FreGAN, self).__init__()
        self.h = h

        self.num_kernels = len(h.resblock_kernel_sizes)
        self.num_upsamples = len(h.upsample_rates)
        self.upsample_rates = h.upsample_rates
        self.up_kernels = h.upsample_kernel_sizes
        self.cond_level = self.num_upsamples - top_k
        self.conv_pre = nn.utils.parametrizations.weight_norm(Conv1d(80, h.upsample_initial_channel, 7, 1, padding=3))
        resblock = ResBlock1 if h.resblock == '1' else ResBlock2

        self.ups = nn.ModuleList()
        self.cond_up = nn.ModuleList()
        self.res_output = nn.ModuleList()
        upsample_ = 1
        kr = 80

        for i, (u, k) in enumerate(zip(self.upsample_rates, self.up_kernels)):
            self.ups.append(nn.utils.parametrizations.weight_norm(ConvTranspose1d(h.upsample_initial_channel//(2**i),
                            h.upsample_initial_channel//(2**(i+1)),
                            k, u, padding=(u//2 + u%2), output_padding=u%2)))

            if i > (self.num_upsamples - top_k):
                self.res_output.append(
                    nn.Sequential(
                        nn.Upsample(scale_factor=u, mode='nearest'),
                        nn.utils.parametrizations.weight_norm(nn.Conv1d(h.upsample_initial_channel // (2 ** i),
                                              h.upsample_initial_channel // (2 ** (i + 1)), 1))
                    )
                )
            if i >= (self.num_upsamples - top_k):
                self.cond_up.append(
                    nn.utils.parametrizations.weight_norm(
                        ConvTranspose1d(kr, h.upsample_initial_channel // (2 ** i),
                                        self.up_kernels[i - 1], self.upsample_rates[i - 1],
                                        padding=(self.upsample_rates[i-1]//2+self.upsample_rates[i-1]%2), output_padding=self.upsample_rates[i-1]%2))
                )
                kr = h.upsample_initial_channel // (2 ** i)

            upsample_ *= u

        self.resblocks = nn.ModuleList()
        for i in range(len(self.ups)):
            ch = h.upsample_initial_channel // (2 ** (i + 1))
            for j, (k, d) in enumerate(zip(h.resblock_kernel_sizes, h.resblock_dilation_sizes)):
                self.resblocks.append(resblock(h, ch, k, d))

        self.conv_post = nn.utils.parametrizations.weight_norm(Conv1d(ch, 1, 7, 1, padding=3))
        self.ups.apply(init_weights)
        self.conv_post.apply(init_weights)
        self.cond_up.apply(init_weights)
        self.res_output.apply(init_weights)
//  [python]
def __init__(self, input_size, hidden_size, bias=True):
        super().__init__()
        self.f = torch.nn.Sequential(
            torch.nn.utils.weight_norm(torch.nn.Linear(input_size, hidden_size)),
            torch.nn.Tanh(),
            torch.nn.utils.weight_norm(torch.nn.Linear(hidden_size, 1, bias=bias)),
        )
        if bias:
            self.f[-1].bias.data[:] = 5.0