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","."]
code: def __init__(
      self,
      in_channels,
      out_channels,
      hidden_channels,
      hidden_channels_ffn,
      num_heads,
      num_layers,
      kernel_size=1,
      dropout_p=0.0,
      rel_attn_window_size=None,
      input_length=None,
  ):
      super().__init__()
      self.hidden_channels = hidden_channels
      self.hidden_channels_ffn = hidden_channels_ffn
      self.num_heads = num_heads
      self.num_layers = num_layers
      self.kernel_size = kernel_size
      self.dropout_p = dropout_p
      self.rel_attn_window_size = rel_attn_window_size
  
      self.dropout = nn.Dropout(dropout_p)
      self.attn_layers = nn.ModuleList()
      self.norm_layers_1 = nn.ModuleList()
      self.ffn_layers = nn.ModuleList()
      self.norm_layers_2 = nn.ModuleList()
  
      for idx in range(self.num_layers):
          self.attn_layers.append(
              RelativePositionMultiHeadAttention(
                  hidden_channels if idx != 0 else in_channels,
                  hidden_channels,
                  num_heads,
                  rel_attn_window_size=rel_attn_window_size,
                  dropout_p=dropout_p,
                  input_length=input_length,
              )
          )
          self.norm_layers_1.append(LayerNorm(hidden_channels))
  
          if (
              hidden_channels != out_channels
              and (idx + 1) == self.num_layers
          ):
              self.proj = nn.Conv1d(hidden_channels, out_channels, 1)
  
          self.ffn_layers.append(
              FeedForwardNetwork(
                  hidden_channels,
                  hidden_channels
                  if (idx + 1) != self.num_layers
                  else out_channels,
                  hidden_channels_ffn,
                  kernel_size,
                  dropout_p=dropout_p,
              )
          )
  
          self.norm_layers_2.append(
              LayerNorm(
                  hidden_channels
                  if (idx + 1) != self.num_layers
                  else out_channels
              )
          )
  
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 1 to create a new RelativePositionTransformer object from inherited base classes: nn with example: obj = RelativePositionTransformer(in_channels, out_channels, hidden_channels, hidden_channels_ffn, num_heads, num_layers, kernel_size, dropout_p, rel_attn_window_size, input_length)