class_docstr: Inject some information about the relative or absolute position of the tokens
      in the sequence. The positional encodings have the same dimension as
      the embeddings, so that the two can be summed. Here, we use sine and cosine
      functions of different frequencies.
  .. math::
              ext{PosEncoder}(pos, 2i) = sin(pos/10000^(2i/d_model))
              ext{PosEncoder}(pos, 2i+1) = cos(pos/10000^(2i/d_model))
              ext{where pos is the word position and i is the embed idx)
  Args:
      d_model: the embed dim (required).
      dropout: the dropout value (default=0.1).
      max_len: the max. length of the incoming sequence (default=5000).
  Examples:
      >>> pos_encoder = PositionalEncoding(d_model)
class_docstr_tok: ["Inject","some","information","about","the","relative","or","absolute","position","of","the","tokens","in","the","sequence",".","The","positional","encodings","have","the","same","dimension","as","the","embeddings",",","so","that","the","two","can","be","summed",".","Here",",","we","use","sine","and","cosine","functions","of","different","frequencies",".","..","math",":",":","ext","{","PosEncoder","}","(","pos",",","2i",")","=","sin","(","pos\/10000^","(","2i\/d_model",")",")","ext","{","PosEncoder","}","(","pos",",","2i+1",")","=","cos","(","pos\/10000^","(","2i\/d_model",")",")","ext","{","where","pos","is","the","word","position","and","i","is","the","embed","idx",")","Args",":","d_model",":","the","embed","dim","(","required",")",".","dropout",":","the","dropout","value","(","default=0.1",")",".","max_len",":","the","max",".","length","of","the","incoming","sequence","(","default=5000",")",".","Examples",":",">",">",">","pos_encoder","=","PositionalEncoding","(","d_model",")"]
docstr: Inputs of forward function
  Args:
      x: the sequence fed to the positional encoder model (required).
  Shape:
      x: [sequence length, batch size, embed dim]
      output: [sequence length, batch size, embed dim]
  Examples:
      >>> output = pos_encoder(x)
docstr_tok: ["Inputs","of","forward","function","Args",":","x",":","the","sequence","fed","to","the","positional","encoder","model","(","required",")",".","Shape",":","x",":","[","sequence","length",",","batch","size",",","embed","dim","]","output",":","[","sequence","length",",","batch","size",",","embed","dim","]","Examples",":",">",">",">","output","=","pos_encoder","(","x",")"]
code: def forward(self, x):
      """Inputs of forward function
      Args:
          x: the sequence fed to the positional encoder model (required).
      Shape:
          x: [sequence length, batch size, embed dim]
          output: [sequence length, batch size, embed dim]
      Examples:
          >>> output = pos_encoder(x)
      """
      x = x.transpose([1, 0, 2])
      x = x + self.pe[: paddle.shape(x)[0], :]
      return self.dropout(x).transpose([1, 0, 2])
  
imports: import math
  import paddle
  from paddle import nn
  import paddle.nn.functional
  from paddle.nn import LayerList
  from paddle.nn import Dropout, Linear, LayerNorm
  import numpy
  from ppocr.modeling.backbones.rec_svtrnet import Mlp, zeros_, ones_
  from paddle.nn.initializer import XavierNormal
label_desc: Use image node_id 2 for calling the PositionalEncoding obj's underlying member method code with example usage: obj.forward(x) and returns: self