code: def __init__(self, dim, cfg: Wav2vec_UConfig):
      super().__init__()
  
      inner_dim = cfg.discriminator_dim
      kernel = cfg.discriminator_kernel
      dilation = cfg.discriminator_dilation
      self.max_pool = cfg.discriminator_max_pool
  
      if cfg.discriminator_causal:
          padding = kernel - 1
      else:
          padding = kernel // 2
  
      def make_conv(in_d, out_d, k, p=0, has_dilation=True):
          conv = nn.Conv1d(
              in_d,
              out_d,
              kernel_size=k,
              padding=p,
              dilation=dilation if has_dilation else 1,
          )
          if cfg.discriminator_spectral_norm:
              conv = nn.utils.spectral_norm(conv)
          elif cfg.discriminator_weight_norm:
              conv = nn.utils.weight_norm(conv)
          return conv
  
      inner_net = [
          nn.Sequential(
              make_conv(inner_dim, inner_dim, kernel, padding),
              SamePad(
                  kernel_size=kernel, causal=cfg.discriminator_causal
              ),
              nn.Dropout(cfg.discriminator_dropout),
              nn.GELU(),
          )
          for _ in range(cfg.discriminator_depth - 1)
      ] + [
          make_conv(inner_dim, 1, kernel, padding, has_dilation=False),
          SamePad(kernel_size=kernel, causal=cfg.discriminator_causal),
      ]
  
      if cfg.discriminator_linear_emb:
          emb_net = [make_conv(dim, inner_dim, 1)]
      else:
          emb_net = [
              make_conv(dim, inner_dim, kernel, padding),
              SamePad(
                  kernel_size=kernel, causal=cfg.discriminator_causal
              ),
          ]
  
      if cfg.discriminator_act_after_linear:
          emb_net.append(nn.GELU())
  
      self.net = nn.Sequential(
          *emb_net,
          nn.Dropout(cfg.discriminator_dropout),
          *inner_net,
      )
  
imports: from dataclasses import dataclass
  from enum import Enum, auto
  import math
  import numpy
  from typing import Tuple, List, Optional, Dict
  import torch
  import torch.nn
  import torch.nn.functional
  from torch import autograd
  from fairseq import checkpoint_utils, utils
  from fairseq.dataclass import FairseqDataclass
  from fairseq.models import BaseFairseqModel, register_model
  from fairseq.modules import SamePad, TransposeLast
label_desc: Use image node_id 1 to create a new Discriminator object from inherited base classes: nn with example: obj = Discriminator(dim, cfg)