class_docstr: ## Graph Attention Network v2 (GATv2)
  
  This graph attention network has two [graph attention layers](index.html).
class_docstr_tok: ["#","#","Graph","Attention","Network","v2","(","GATv2",")","This","graph","attention","network","has","two","[","graph","attention","layers","]","(","index.html",")","."]
docstr: * `in_features` is the number of features per node
  * `n_hidden` is the number of features in the first graph attention layer
  * `n_classes` is the number of classes
  * `n_heads` is the number of heads in the graph attention layers
  * `dropout` is the dropout probability
  * `share_weights` if set to True, the same matrix will be applied to the source and the target node of every edge
docstr_tok: ["*","`","in_features","`","is","the","number","of","features","per","node","*","`","n_hidden","`","is","the","number","of","features","in","the","first","graph","attention","layer","*","`","n_classes","`","is","the","number","of","classes","*","`","n_heads","`","is","the","number","of","heads","in","the","graph","attention","layers","*","`","dropout","`","is","the","dropout","probability","*","`","share_weights","`","if","set","to","True",",","the","same","matrix","will","be","applied","to","the","source","and","the","target","node","of","every","edge"]
code: def __init__(
      self,
      in_features: int,
      n_hidden: int,
      n_classes: int,
      n_heads: int,
      dropout: float,
      share_weights: bool = True,
  ):
      """
      * `in_features` is the number of features per node
      * `n_hidden` is the number of features in the first graph attention layer
      * `n_classes` is the number of classes
      * `n_heads` is the number of heads in the graph attention layers
      * `dropout` is the dropout probability
      * `share_weights` if set to True, the same matrix will be applied to the source and the target node of every edge
      """
      super().__init__()
  
      # First graph attention layer where we concatenate the heads
      self.layer1 = GraphAttentionV2Layer(
          in_features,
          n_hidden,
          n_heads,
          is_concat=True,
          dropout=dropout,
          share_weights=share_weights,
      )
      # Activation function after first graph attention layer
      self.activation = nn.ELU()
      # Final graph attention layer where we average the heads
      self.output = GraphAttentionV2Layer(
          n_hidden,
          n_classes,
          1,
          is_concat=False,
          dropout=dropout,
          share_weights=share_weights,
      )
      # Dropout
      self.dropout = nn.Dropout(dropout)
  
file_path: annotated_deep_learning_paper_implementations/labml_nn/graphs/gatv2/experiment.py
imports: import torch
  from torch import nn
  from labml import experiment
  from labml.configs import option
  from labml_helpers.module import Module
  from labml_nn.graphs.gat.experiment import Configs
  from labml_nn.graphs.gatv2 import GraphAttentionV2Layer
label_desc: Use image node_id 1 to create a new GATv2 object from inherited base classes: Module with example: obj = GATv2(in_features, n_hidden, n_classes, n_heads, dropout, share_weights)