def forward(self, src, seg):
        """Embed inputs.
        Args:
            emb (FloatTensor): Sequence of word vectors
                ``(batch_size, seq_len, self.dim)``
            step (int or NoneType): If stepwise (``seq_len = 1``), use
                the encoding for this position.
        """
        if seg is not None:
            batch_size, seq_length = seg.size()
            device = seg.device
            no_pad_num = seg.sum(dim=-1)
        else:
            batch_size, seq_length = src.size()
            device = src.device
            no_pad_num = (src != 0).sum(dim=-1)
        
        emb =  torch.zeros(batch_size, seq_length, self.emb_size)
        for i in range(batch_size):
            emb[i, :no_pad_num[i], :] = self.emb[2: no_pad_num[i]+2]

        return emb.to(device)
Embed inputs.
        Args:
            emb (FloatTensor): Sequence of word vectors
                ``(batch_size, seq_len, self.dim)``
            step (int or NoneType): If stepwise (``seq_len = 1``), use
                the encoding for this position.
        
uer/embeddings/sinusoidalpos_embedding.py