class_docstr: Implementation of the Transformer Sentence Encoder. This directly makes
  use of the TransformerSentenceEncoder module in Fairseq.
  
  A few interesting config options:
      - encoder_normalize_before detemines whether the layer norm is applied
        before or after self_attention. This is similar to original
        implementation from Google.
      - activation_fn can be set to 'gelu' instead of the default of 'relu'.
code: def __init__(
      self,
      config: Config,
      output_encoded_layers: bool,
      padding_idx: int,
      vocab_size: int,
      *args,
      **kwarg,
  ) -> None:
      super().__init__(
          config, output_encoded_layers=output_encoded_layers
      )
      self.multilingual = config.multilingual
      self.offset_positions_by_padding = (
          config.offset_positions_by_padding
      )
      self.use_torchscript = config.use_torchscript
      self.use_bias_finetuning = config.use_bias_finetuning
      self.traced_encoder = None
  
      self.sentence_encoder = TransformerSentenceEncoderModule(
          padding_idx=padding_idx,
          vocab_size=vocab_size,
          num_encoder_layers=config.num_encoder_layers,
          embedding_dim=config.embedding_dim,
          ffn_embedding_dim=config.ffn_embedding_dim,
          num_attention_heads=config.num_attention_heads,
          dropout=config.dropout,
          attention_dropout=config.attention_dropout,
          activation_dropout=config.activation_dropout,
          max_seq_len=config.max_seq_len,
          num_segments=config.num_segments,
          use_position_embeddings=config.use_position_embeddings,
          offset_positions_by_padding=config.offset_positions_by_padding,
          encoder_normalize_before=config.encoder_normalize_before,
          apply_bert_init=config.apply_bert_init,
          activation_fn=config.activation_fn,
          freeze_embeddings=config.freeze_embeddings,
          n_trans_layers_to_freeze=config.n_trans_layers_to_freeze,
          export=self.export,
      )
      if self.use_torchscript:
          assert hasattr(self.sentence_encoder, "traceable")
          self.sentence_encoder.traceable = self.use_torchscript
      if self.use_bias_finetuning:
          for n, p in self.sentence_encoder.named_parameters():
              # "sentence_encoder.layers.0.self_attn.k_proj.weight" -> false
              # "sentence_encoder.layers.0.self_attn.k_proj.bias" -> true
              if n.split(".")[-1] != "bias":
                  p.requires_grad_(False)
  
      log_class_usage(__class__)
  
file_path: pytext/pytext/models/representations/transformer_sentence_encoder.py
imports: from typing import Tuple
  import torch
  from fairseq.modules import TransformerSentenceEncoder
  from pytext.config import ConfigBase
  from pytext.models.representations.traced_transformer_encoder import TracedTransformerEncoder
  from pytext.models.representations.transformer_sentence_encoder_base import TransformerSentenceEncoderBase
  from pytext.utils.usage import log_class_usage
label_desc: Use image node_id 1 to create a new TransformerSentenceEncoder object from inherited base classes: TransformerSentenceEncoderBase with example: obj = TransformerSentenceEncoder(config, output_encoded_layers, padding_idx, vocab_size)