class_docstr: Configuration class to store `Fixed` sparsity configuration.
  For more details about this sparsity config, please see `Generative Modeling with
  Sparse Transformers`: https://arxiv.org/abs/1904.10509; this has been customized.
  This class extends parent class of `SparsityConfig` and customizes it for `Fixed` sparsity.
class_docstr_tok: ["Configuration","class","to","store","`","Fixed","`","sparsity","configuration",".","For","more","details","about","this","sparsity","config",",","please","see","`","Generative","Modeling","with","Sparse","Transformers","`",":","https",":","\/\/arxiv.org\/abs\/1904.10509",";","this","has","been","customized",".","This","class","extends","parent","class","of","`","SparsityConfig","`","and","customizes","it","for","`","Fixed","`","sparsity","."]
docstr: Sets local attention layout used by the given head in the sparse attention.
  Arguments:
       h: required: an integer determining head index
       layout: required: a tensor of dimension (num_heads, num_blocks, num_blocks) containing
          sparsity layout of all head; may not be completely set at this step
  Return:
       layout: a tensor of dimension (num_heads, num_blocks, num_blocks) containing sparsity
          layout of all head in which local layout is set
docstr_tok: ["Sets","local","attention","layout","used","by","the","given","head","in","the","sparse","attention",".","Arguments",":","h",":","required",":","an","integer","determining","head","index","layout",":","required",":","a","tensor","of","dimension","(","num_heads",",","num_blocks",",","num_blocks",")","containing","sparsity","layout","of","all","head",";","may","not","be","completely","set","at","this","step","Return",":","layout",":","a","tensor","of","dimension","(","num_heads",",","num_blocks",",","num_blocks",")","containing","sparsity","layout","of","all","head","in","which","local","layout","is","set"]
code: def set_local_layout(self, h, layout):
      """Sets local attention layout used by the given head in the sparse attention.
      Arguments:
           h: required: an integer determining head index
           layout: required: a tensor of dimension (num_heads, num_blocks, num_blocks) containing
              sparsity layout of all head; may not be completely set at this step
      Return:
           layout: a tensor of dimension (num_heads, num_blocks, num_blocks) containing sparsity
              layout of all head in which local layout is set
      """
  
      num_blocks = layout.shape[1]
      for i in range(0, num_blocks, self.num_local_blocks):
          end = min(i + self.num_local_blocks, num_blocks)
          for row in range(i, end):
              for col in range(
                  i,
                  (
                      row + 1
                      if self.attention == "unidirectional"
                      else end
                  ),
              ):
                  layout[h, row, col] = 1
      return layout
  
imports: import random
  import torch
label_desc: Use image node_id 2 for calling the FixedSparsityConfig obj's underlying member method code with example usage: obj.set_local_layout(h, layout) and returns: layout