class_docstr: Transformer class.
  Args:
      d_model (int): model dimension
      nhead (int): number of heads
      num_glance_enc_layers (int): number of glance encoder layers
      num_gaze_s1_dec_layers (int): number of gaze s1 decoder layers
      num_gaze_s2_dec_layers (int): number of gaze s2 decoder layers
      dim_feedforward (int): dimension of feedforward
      dropout (int): drop out probability
      activation (str): activation
class_docstr_tok: ["Transformer","class",".","Args",":","d_model","(","int",")",":","model","dimension","nhead","(","int",")",":","number","of","heads","num_glance_enc_layers","(","int",")",":","number","of","glance","encoder","layers","num_gaze_s1_dec_layers","(","int",")",":","number","of","gaze","s1","decoder","layers","num_gaze_s2_dec_layers","(","int",")",":","number","of","gaze","s2","decoder","layers","dim_feedforward","(","int",")",":","dimension","of","feedforward","dropout","(","int",")",":","drop","out","probability","activation","(","str",")",":","activation"]
code: def __init__(
      self,
      d_model=512,
      nhead=8,
      num_glance_enc_layers=3,
      num_gaze_s1_dec_layers=3,
      num_gaze_s1_enc_layers=3,
      num_gaze_s2_dec_layers=3,
      dim_feedforward=2048,
      dropout=0.15,
      activation="relu",
  ):
      super().__init__()
  
      self.d_model = d_model
      self.nhead = nhead
      self.num_verb_classes = 504
  
      # Glacne Transformer
      glance_enc_layer = TransformerEncoderLayer(
          d_model, nhead, dim_feedforward, dropout, activation
      )
      self.glance_enc = TransformerEncoder(
          glance_enc_layer, num_glance_enc_layers
      )
  
      # Gaze-Step1 Transformer
      gaze_s1_dec_layer = TransformerDecoderLayer(
          d_model, nhead, dim_feedforward, dropout, activation
      )
      self.gaze_s1_dec = TransformerDecoder(
          gaze_s1_dec_layer, num_gaze_s1_dec_layers
      )
      gaze_s1_enc_layer = TransformerEncoderLayer(
          d_model, nhead, dim_feedforward, dropout, activation
      )
      self.gaze_s1_enc = TransformerEncoder(
          gaze_s1_enc_layer, num_gaze_s1_enc_layers
      )
  
      # Gaze-Step2 Transformer
      gaze_s2_dec_layer = TransformerDecoderLayer(
          d_model, nhead, dim_feedforward, dropout, activation
      )
      self.gaze_s2_dec = TransformerDecoder(
          gaze_s2_dec_layer, num_gaze_s2_dec_layers
      )
  
      # classifer (for verb prediction)
      self.verb_classifier = nn.Sequential(
          nn.Linear(d_model * 2, d_model * 2),
          nn.ReLU(),
          nn.Dropout(0.3),
          nn.Linear(d_model * 2, self.num_verb_classes),
      )
  
      # layer norms
      self.ln1 = nn.LayerNorm(d_model)
      self.ln2 = nn.LayerNorm(d_model * 2)
      self.ln3 = nn.LayerNorm(d_model)
      self.ln4 = nn.LayerNorm(d_model)
  
      self._reset_parameters()
  
imports: import copy
  import torch
  import torch.nn.functional
  from typing import Optional
  from torch import nn, Tensor
label_desc: Use image node_id 1 to create a new Transformer object from inherited base classes: nn with example: obj = Transformer(d_model, nhead, num_glance_enc_layers, num_gaze_s1_dec_layers, num_gaze_s1_enc_layers, num_gaze_s2_dec_layers, dim_feedforward, dropout, activation)