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 into overlapping chunks.
  
  Args:
      x (torch.Tensor): # (batch x head, time, size)
      w (int): Chunk overlap size
  
  Returns:
      output (torch.Tensor): # (batch x head, chunk_count, 2w, size)
docstr_tok: ["Convert","into","overlapping","chunks",".","Args",":","x","(","torch.Tensor",")",":","#","(","batch","x","head",",","time",",","size",")","w","(","int",")",":","Chunk","overlap","size","Returns",":","output","(","torch.Tensor",")",":","#","(","batch","x","head",",","chunk_count",",","2w",",","size",")"]
code: def _chunk_overlap(self, x: torch.Tensor, w: int) -> torch.Tensor:
      """Convert into overlapping chunks.
  
      Args:
          x (torch.Tensor): # (batch x head, time, size)
          w (int): Chunk overlap size
  
      Returns:
          output (torch.Tensor): # (batch x head, chunk_count, 2w, size)
      """
  
      # non-overlapping chunks of size = 2w
      x = x.view(x.size(0), x.size(1) // (w * 2), w * 2, x.size(2))
  
      # use `as_strided` to make the chunks overlap with an overlap size = w
      chunk_size = list(x.size())
      chunk_size[1] = chunk_size[1] * 2 - 1
  
      chunk_stride = list(x.stride())
      chunk_stride[1] = chunk_stride[1] // 2
      return x.as_strided(size=chunk_size, stride=chunk_stride)
  
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 9 for calling the RelPositionMultiHeadAttentionLongformer obj's underlying member method code with example usage: obj._chunk_overlap(x, w) and returns: x