docstr: Groups the linear layers belonging to the same attention layer in a model.
  Currently, we only capture weights in attention layers with forward computations written
  as four Linear layers (projections for Q, K, V, and output) and two matmul operations.
  The method implemented here can work for Huggingface transformers but may not correctly
  capture transformers written in other fashions (e.g., torch.nn.Transformer).
  
  Parameters
  ----------
  model : torch.nn.Module
      The model to be analyzed.
  dummy_input : torch.Tensor
      The example input data to trace the network architecture.
  traced_model : torch._C.Graph
      if we already have the traced graph of the target model, we do not
      need to trace the model again.
docstr_tok: ["Groups","the","linear","layers","belonging","to","the","same","attention","layer","in","a","model",".","Currently",",","we","only","capture","weights","in","attention","layers","with","forward","computations","written","as","four","Linear","layers","(","projections","for","Q",",","K",",","V",",","and","output",")","and","two","matmul","operations",".","The","method","implemented","here","can","work","for","Huggingface","transformers","but","may","not","correctly","capture","transformers","written","in","other","fashions","(","e.g.",",","torch.nn.Transformer",")",".","Parameters","--","--","--","--","--","model",":","torch.nn.Module","The","model","to","be","analyzed",".","dummy_input",":","torch.Tensor","The","example","input","data","to","trace","the","network","architecture",".","traced_model",":","torch._C.Graph","if","we","already","have","the","traced","graph","of","the","target","model",",","we","do","not","need","to","trace","the","model","again","."]
code: def __init__(self, model=None, dummy_input=None, traced_model=None):
      """
      Groups the linear layers belonging to the same attention layer in a model.
      Currently, we only capture weights in attention layers with forward computations written
      as four Linear layers (projections for Q, K, V, and output) and two matmul operations.
      The method implemented here can work for Huggingface transformers but may not correctly
      capture transformers written in other fashions (e.g., torch.nn.Transformer).
  
      Parameters
      ----------
      model : torch.nn.Module
          The model to be analyzed.
      dummy_input : torch.Tensor
          The example input data to trace the network architecture.
      traced_model : torch._C.Graph
          if we already have the traced graph of the target model, we do not
          need to trace the model again.
      """
      super(AttentionWeightDependency, self).__init__(
          model, dummy_input, traced_model
      )
  
imports: import csv
  import logging
  import torch
  import numpy
  from .attr import get_nested_attr
label_desc: Use image node_id 1 to create a new AttentionWeightDependency object from inherited base classes: Dependency with example: obj = AttentionWeightDependency(model, dummy_input, traced_model)