class_docstr: Relative positional encoding for sliding window attention or chunked attention.
  See above for relative positional encoding based on Transformer-XL paper
  Args:
      left_chunk_size (int): number of frames to in past chunks
      chunk size (int): number of frames (max frames if using multimode) in current chunk
      d_model (int): embedding dim
      dropout_rate (float): dropout rate
      max_len (int): maximum input length
      xscale (bool): whether to scale the input by sqrt(d_model)
      dropout_rate_emb (float): dropout rate for the positional embeddings
class_docstr_tok: ["Relative","positional","encoding","for","sliding","window","attention","or","chunked","attention",".","See","above","for","relative","positional","encoding","based","on","Transformer-XL","paper","Args",":","left_chunk_size","(","int",")",":","number","of","frames","to","in","past","chunks","chunk","size","(","int",")",":","number","of","frames","(","max","frames","if","using","multimode",")","in","current","chunk","d_model","(","int",")",":","embedding","dim","dropout_rate","(","float",")",":","dropout","rate","max_len","(","int",")",":","maximum","input","length","xscale","(","bool",")",":","whether","to","scale","the","input","by","sqrt","(","d_model",")","dropout_rate_emb","(","float",")",":","dropout","rate","for","the","positional","embeddings"]
docstr: Reset and extend the positional encodings only at the beginning
docstr_tok: ["Reset","and","extend","the","positional","encodings","only","at","the","beginning"]
code: def extend_pe(self, length, device):
      """Reset and extend the positional encodings only at the beginning"""
      if hasattr(self, "pe"):
          return
  
      positions = torch.arange(
          self.left_context,
          -self.right_context - 1,
          -1,
          dtype=torch.float32,
          device=device,
      ).unsqueeze(1)
      self.create_pe(positions=positions)
  
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 2 for calling the LocalAttRelPositionalEncoding obj's underlying member method code with example usage: obj.extend_pe(length, device) without return types