class_docstr: Sinusoidal positional encoding for non-recurrent neural networks.
  Implementation based on "Attention Is All You Need"
  Args:
     channels (int): embedding size
     dropout (float): dropout parameter
class_docstr_tok: ["Sinusoidal","positional","encoding","for","non-recurrent","neural","networks",".","Implementation","based","on","``","Attention","Is","All","You","Need","''","Args",":","channels","(","int",")",":","embedding","size","dropout","(","float",")",":","dropout","parameter"]
code: def __init__(self, channels, dropout=0.0, max_len=5000):
      super().__init__()
      if channels % 2 != 0:
          raise ValueError(
              "Cannot use sin/cos positional encoding with "
              "odd channels (got channels={:d})".format(channels)
          )
      pe = torch.zeros(max_len, channels)
      position = torch.arange(0, max_len).unsqueeze(1)
      div_term = torch.exp(
          (
              torch.arange(0, channels, 2, dtype=torch.float)
              * -(math.log(10000.0) / channels)
          )
      )
      pe[:, 0::2] = torch.sin(position.float() * div_term)
      pe[:, 1::2] = torch.cos(position.float() * div_term)
      pe = pe.unsqueeze(0).transpose(1, 2)
      self.register_buffer("pe", pe)
      if dropout > 0:
          self.dropout = nn.Dropout(p=dropout)
      self.channels = channels
  
imports: import math
  import torch
  from torch import nn
  from TTS.tts.layers.glow_tts.transformer import RelativePositionTransformer
  from TTS.tts.layers.generic.res_conv_bn import ResidualConv1dBNBlock
label_desc: Use image node_id 1 to create a new PositionalEncoding object from inherited base classes: nn with example: obj = PositionalEncoding(channels, dropout, max_len)