class_docstr: Relative positional encoding.
  
  Args:
      size: Module size.
      max_len: Maximum input length.
      dropout_rate: Dropout rate.
docstr: Reset positional encoding.
  
  Args:
      x: Input sequences. (B, T, ?)
      left_context: Number of previous frames the attention module can see
                    in current chunk.
docstr_tok: ["Reset","positional","encoding",".","Args",":","x",":","Input","sequences",".","(","B",",","T",",","?",")","left_context",":","Number","of","previous","frames","the","attention","module","can","see","in","current","chunk","."]
code: def extend_pe(self, x: torch.Tensor, left_context: int = 0) -> None:
      """Reset positional encoding.
  
      Args:
          x: Input sequences. (B, T, ?)
          left_context: Number of previous frames the attention module can see
                        in current chunk.
  
      """
      time1 = x.size(1) + left_context
  
      if self.pe is not None:
          if self.pe.size(1) >= time1 * 2 - 1:
              if self.pe.dtype != x.dtype or self.pe.device != x.device:
                  self.pe = self.pe.to(device=x.device, dtype=x.dtype)
              return
  
      pe_positive = torch.zeros(time1, self.size)
      pe_negative = torch.zeros(time1, self.size)
  
      position = torch.arange(0, time1, dtype=torch.float32).unsqueeze(
          1
      )
      div_term = torch.exp(
          torch.arange(0, self.size, 2, dtype=torch.float32)
          * -(math.log(10000.0) / self.size)
      )
  
      pe_positive[:, 0::2] = torch.sin(position * div_term)
      pe_positive[:, 1::2] = torch.cos(position * div_term)
      pe_positive = torch.flip(pe_positive, [0]).unsqueeze(0)
  
      pe_negative[:, 0::2] = torch.sin(-1 * position * div_term)
      pe_negative[:, 1::2] = torch.cos(-1 * position * div_term)
      pe_negative = pe_negative[1:].unsqueeze(0)
  
      self.pe = torch.cat([pe_positive, pe_negative], dim=1).to(
          dtype=x.dtype, device=x.device
      )
  
imports: import math
  import torch
  from espnet.nets.pytorch_backend.transformer.embedding import _pre_hook
label_desc: Use image node_id 2 for calling the RelPositionalEncoding obj's underlying member method code with example usage: obj.extend_pe(x, left_context) without return types