class_docstr: Transformer with Relative Potional Encoding.
  https://arxiv.org/abs/1803.02155
  
  Args:
      in_channels (int): number of channels of the input tensor.
      out_chanels (int): number of channels of the output tensor.
      hidden_channels (int): model hidden channels.
      hidden_channels_ffn (int): hidden channels of FeedForwardNetwork.
      num_heads (int): number of attention heads.
      num_layers (int): number of transformer layers.
      kernel_size (int, optional): kernel size of feed-forward inner layers. Defaults to 1.
      dropout_p (float, optional): dropout rate for self-attention and feed-forward inner layers_per_stack. Defaults to 0.
      rel_attn_window_size (int, optional): relation attention window size.
          If 4, for each time step next and previous 4 time steps are attended.
          If default, relative encoding is disabled and it is a regular transformer.
          Defaults to None.
      input_length (int, optional): input lenght to limit position encoding. Defaults to None.
class_docstr_tok: ["Transformer","with","Relative","Potional","Encoding",".","https",":","\/\/arxiv.org\/abs\/1803.02155","Args",":","in_channels","(","int",")",":","number","of","channels","of","the","input","tensor",".","out_chanels","(","int",")",":","number","of","channels","of","the","output","tensor",".","hidden_channels","(","int",")",":","model","hidden","channels",".","hidden_channels_ffn","(","int",")",":","hidden","channels","of","FeedForwardNetwork",".","num_heads","(","int",")",":","number","of","attention","heads",".","num_layers","(","int",")",":","number","of","transformer","layers",".","kernel_size","(","int",",","optional",")",":","kernel","size","of","feed-forward","inner","layers",".","Defaults","to","1.","dropout_p","(","float",",","optional",")",":","dropout","rate","for","self-attention","and","feed-forward","inner","layers_per_stack",".","Defaults","to","0.","rel_attn_window_size","(","int",",","optional",")",":","relation","attention","window","size",".","If","4",",","for","each","time","step","next","and","previous","4","time","steps","are","attended",".","If","default",",","relative","encoding","is","disabled","and","it","is","a","regular","transformer",".","Defaults","to","None",".","input_length","(","int",",","optional",")",":","input","lenght","to","limit","position","encoding",".","Defaults","to","None","."]
docstr: Shapes:
      x: [B, C, T]
      x_mask: [B, 1, T]
docstr_tok: ["Shapes",":","x",":","[","B",",","C",",","T","]","x_mask",":","[","B",",","1",",","T","]"]
code: def forward(self, x, x_mask):
      """
      Shapes:
          x: [B, C, T]
          x_mask: [B, 1, T]
      """
      attn_mask = x_mask.unsqueeze(2) * x_mask.unsqueeze(-1)
      for i in range(self.num_layers):
          x = x * x_mask
          y = self.attn_layers[i](x, x, attn_mask)
          y = self.dropout(y)
          x = self.norm_layers_1[i](x + y)
  
          y = self.ffn_layers[i](x, x_mask)
          y = self.dropout(y)
  
          if (i + 1) == self.num_layers and hasattr(self, "proj"):
              x = self.proj(x)
  
          x = self.norm_layers_2[i](x + y)
      x = x * x_mask
      return x
  
imports: import math
  import torch
  from torch import nn
  from torch.nn import functional
  from TTS.tts.layers.glow_tts.glow import LayerNorm
label_desc: Use image node_id 2 for calling the RelativePositionTransformer obj's underlying member method code with example usage: obj.forward(x, x_mask) and returns: x