import math
import megengine.module as M
import megengine.functional as F
import megengine as mge


class PositionalEncoding(M.Module):
    """Positional encoding.

    :param int d_model: embedding dim
    :param float dropout_rate: dropout rate
    :param int max_len: maximum input length

    """

    def __init__(self, d_model, dropout_rate, max_len=5000):
        """Construct an PositionalEncoding object."""
        super(PositionalEncoding, self).__init__()
        self.d_model = d_model
        self.xscale = math.sqrt(self.d_model)
        self.dropout = M.dropout.Dropout(dropout_rate)
        self.pe = 
mge.Tensor(0.0)