code: def __init__(self, cfg, red_fac=2):
      super(Adapter, self).__init__()
      self.cfg = cfg
      self.embed_dim = cfg.encoder_embed_dim
      self.quant_noise = getattr(cfg, "quant_noise_pq", 0)
      self.quant_noise_block_size = (
          getattr(cfg, "quant_noise_pq_block_size", 8) or 8
      )
      self.activation_fn = utils.get_activation_fn(
          activation=getattr(cfg, "activation_fn", "relu") or "relu"
      )
      self.fc1 = quant_noise(
          nn.Linear(self.embed_dim, self.embed_dim // red_fac),
          p=self.quant_noise,
          block_size=self.quant_noise_block_size,
      )
      self.fc2 = quant_noise(
          nn.Linear(self.embed_dim // red_fac, self.embed_dim),
          p=self.quant_noise,
          block_size=self.quant_noise_block_size,
      )
      activation_dropout_p = getattr(cfg, "activation_dropout", 0) or 0
      if activation_dropout_p == 0:
          # for backwards compatibility with models that use cfg.relu_dropout
          activation_dropout_p = getattr(cfg, "relu_dropout", 0) or 0
      self.activation_dropout_module = FairseqDropout(
          float(activation_dropout_p),
          module_name=self.__class__.__name__,
      )
  
file_path: fairseq/fairseq/models/xmod/transformer_layer_xmod.py
imports: from fairseq.modules.transformer_layer import TransformerEncoderLayer
  from typing import Optional
  import torch
  import torch.nn
  from fairseq import utils
  from fairseq.modules import LayerNorm
  from fairseq.modules.fairseq_dropout import FairseqDropout
  from fairseq.modules.quant_noise import quant_noise
  from torch import Tensor
label_desc: Use image node_id 1 to create a new Adapter object from inherited base classes: nn with example: obj = Adapter(cfg, red_fac)