class_docstr: Sparse Multi-Headed Attention.
  
  "Generating Long Sequences with Sparse Transformers". Implements
  fixed factorized self attention, where l=stride and c=expressivity.
  A(1) includes all words in the stride window and A(2) takes a summary of c
  words from the end of each stride window.
  If is_bidirectional=False, we do not include any words past the current word,
  as in the paper.
class_docstr_tok: ["Sparse","Multi-Headed","Attention",".","``","Generating","Long","Sequences","with","Sparse","Transformers","''",".","Implements","fixed","factorized","self","attention",",","where","l=stride","and","c=expressivity",".","A","(","1",")","includes","all","words","in","the","stride","window","and","A","(","2",")","takes","a","summary","of","c","words","from","the","end","of","each","stride","window",".","If","is_bidirectional=False",",","we","do","not","include","any","words","past","the","current","word",",","as","in","the","paper","."]
code: def compute_checkpoint(self, word_index):
      if word_index % self.stride == 0 and word_index != 0:
          checkpoint_index = word_index - self.expressivity
      else:
          checkpoint_index = (
              math.floor(word_index / self.stride) * self.stride
              + self.stride
              - self.expressivity
          )
      return checkpoint_index
  
file_path: fairseq/fairseq/modules/sparse_multihead_attention.py
imports: import math
  import torch
  from .multihead_attention import MultiheadAttention
label_desc: Use image node_id 2 for calling the SparseMultiheadAttention obj's underlying member method code with example usage: obj.compute_checkpoint(word_index) and returns: checkpoint_index