class_docstr: This is a TorchScriptable implementation of MultiheadLinearAttention:
  https://arxiv.org/pdf/2006.04768.pdf. from fairseq for the purposes of
  creating a productionized Linformer model. It distills just
  the elements which are required to implement the RoBERTa use cases of
  MultiheadLinearAttention, and within that is restructured and rewritten to be able
  to be compiled by TorchScript for production use cases.
  
  The default constructor values match those required to import the public
  RoBERTa weights. Unless you are pretraining your own model, there's no need to
  change them.
class_docstr_tok: ["This","is","a","TorchScriptable","implementation","of","MultiheadLinearAttention",":","https",":","\/\/arxiv.org\/pdf\/2006.04768.pdf",".","from","fairseq","for","the","purposes","of","creating","a","productionized","Linformer","model",".","It","distills","just","the","elements","which","are","required","to","implement","the","RoBERTa","use","cases","of","MultiheadLinearAttention",",","and","within","that","is","restructured","and","rewritten","to","be","able","to","be","compiled","by","TorchScript","for","production","use","cases",".","The","default","constructor","values","match","those","required","to","import","the","public","RoBERTa","weights",".","Unless","you","are","pretraining","your","own","model",",","there","'s","no","need","to","change","them","."]
code: def prune_multi_linear_heads(self, heads: List[int]):
      mask = torch.ones(self.num_heads, self.head_dim)
      for head in heads:
          mask[head] = 0
      mask = mask.view(-1).contiguous().eq(1)
      if torch.onnx.is_in_onnx_export():
          index = np.arange(len(mask), dtype=np.int64)
          index = torch.from_numpy(index).to(device=mask.device)
      else:
          index = torch.arange(
              len(mask), dtype=torch.long, device=mask.device
          )
  
      # Prune linear layers
      self.kput_projection = self._prune_linear_layer(
          self.kput_projection, index[mask], dim=0
      )
      self.qput_projection = self._prune_linear_layer(
          self.qput_projection, index[mask], dim=0
      )
      self.vput_projection = self._prune_linear_layer(
          self.vput_projection, index[mask], dim=0
      )
      self.output_projection = self._prune_linear_layer(
          self.output_projection, index[mask], dim=1
      )
      # Update hyper params
      self.num_heads = self.num_heads - len(heads)
  
file_path: pytext/pytext/models/representations/transformer/multihead_linear_attention.py
imports: from typing import List, Tuple
  import numpy
  import torch
  from pytext.utils.usage import log_class_usage
  from torch import nn
  from torch.nn import functional
label_desc: Use image node_id 2 for calling the MultiheadLinearAttention obj's underlying member method code with example usage: obj.prune_multi_linear_heads(heads) without return types