class_docstr: Multi-Head Attention layer of Transformer-XL with sliding window local+global attention from Longformer.
  Partially adapted from allenai (https://github.com/allenai/longformer/blob/master/longformer/sliding_chunks.py)
  and huggingface (https://github.com/huggingface/transformers/blob/main/src/transformers/models/longformer/modeling_longformer.py) 
  Paper: https://arxiv.org/abs/1901.02860 (Transformer-XL),
         https://arxiv.org/abs/2004.05150 (Longformer)
  Args:
      n_head (int): number of heads
      n_feat (int): size of the features
      dropout_rate (float): dropout rate
      pos_bias_u (Tensor): the positional bias matrix U
      pos_bias_v (Tensor): the positional bias matrix V
      att_context_size (List[int]): List of 2 ints corresponding to left and right attention context sizes.
      max_cache_len (int): the maximum size of cache
      global_tokens (int): number of tokens to be used for global attention
      global_tokens_spacing (int): how far apart the global tokens are
      global_attn_separate (bool): whether the q, k, v layers used for global tokens should be separate
class_docstr_tok: ["Multi-Head","Attention","layer","of","Transformer-XL","with","sliding","window","local+global","attention","from","Longformer",".","Partially","adapted","from","allenai","(","https",":","\/\/github.com\/allenai\/longformer\/blob\/master\/longformer\/sliding_chunks.py",")","and","huggingface","(","https",":","\/\/github.com\/huggingface\/transformers\/blob\/main\/src\/transformers\/models\/longformer\/modeling_longformer.py",")","Paper",":","https",":","\/\/arxiv.org\/abs\/1901.02860","(","Transformer-XL",")",",","https",":","\/\/arxiv.org\/abs\/2004.05150","(","Longformer",")","Args",":","n_head","(","int",")",":","number","of","heads","n_feat","(","int",")",":","size","of","the","features","dropout_rate","(","float",")",":","dropout","rate","pos_bias_u","(","Tensor",")",":","the","positional","bias","matrix","U","pos_bias_v","(","Tensor",")",":","the","positional","bias","matrix","V","att_context_size","(","List","[","int","]",")",":","List","of","2","ints","corresponding","to","left","and","right","attention","context","sizes",".","max_cache_len","(","int",")",":","the","maximum","size","of","cache","global_tokens","(","int",")",":","number","of","tokens","to","be","used","for","global","attention","global_tokens_spacing","(","int",")",":","how","far","apart","the","global","tokens","are","global_attn_separate","(","bool",")",":","whether","the","q",",","k",",","v","layers","used","for","global","tokens","should","be","separate"]
docstr: Convert diagonals into columns (or columns into diagonals depending on `direction`
  
  Args:
      x (torch.Tensor): (batch x head, chunk_count, 2w, 2w)
      direction (List[int]): padding directions
      padding_value (float): value to pad with
  
  Returns:
      output (torch.Tensor): (batch x head, chunk_count, 2w, 2w + 1)
docstr_tok: ["Convert","diagonals","into","columns","(","or","columns","into","diagonals","depending","on","`","direction","`","Args",":","x","(","torch.Tensor",")",":","(","batch","x","head",",","chunk_count",",","2w",",","2w",")","direction","(","List","[","int","]",")",":","padding","directions","padding_value","(","float",")",":","value","to","pad","with","Returns",":","output","(","torch.Tensor",")",":","(","batch","x","head",",","chunk_count",",","2w",",","2w","+","1",")"]
code: def _skew(
      self, x: torch.Tensor, direction: List[int], padding_value: float
  ) -> torch.Tensor:
      """Convert diagonals into columns (or columns into diagonals depending on `direction`
  
      Args:
          x (torch.Tensor): (batch x head, chunk_count, 2w, 2w)
          direction (List[int]): padding directions
          padding_value (float): value to pad with
  
      Returns:
          output (torch.Tensor): (batch x head, chunk_count, 2w, 2w + 1)
  
      """
      x_padded = F.pad(x, direction, value=padding_value)
      x_padded = x_padded.view(
          *x_padded.size()[:-2], x_padded.size(-1), x_padded.size(-2)
      )
      return x_padded
  
imports: import math
  from functools import lru_cache
  from typing import List, Tuple
  import torch
  import torch.nn
  import torch.nn.functional
  from nemo.utils import avoid_float16_autocast_context
label_desc: Use image node_id 7 for calling the RelPositionMultiHeadAttentionLongformer obj's underlying member method code with example usage: obj._skew(x, direction, padding_value) and returns: x_padded