(self, input_ids)
return embeddings
Parameters
        ----------
        input_ids: torch.tensor(bs, max_seq_length)
            The token ids to embed.

        Outputs
        -------
        embeddings: torch.tensor(bs, max_seq_length, dim)
            The embedded tokens (plus position embeddings, no token_type embeddings)
Parameters
        ----------
        input_ids: torch.tensor(bs, max_seq_length)
            The token ids to embed.
Parameters ---------- input_ids : torch . tensor ( bs max_seq_length ) The token ids to embed .
def forward(self, input_ids):
        """
        Parameters
        ----------
        input_ids: torch.tensor(bs, max_seq_length)
            The token ids to embed.

        Outputs
        -------
        embeddings: torch.tensor(bs, max_seq_length, dim)
            The embedded tokens (plus position embeddings, no token_type embeddings)
        """
        seq_length = input_ids.size(1)
        position_ids = torch.arange(seq_length, dtype=torch.long, device=input_ids.device) # (max_seq_length)
        position_ids = position_ids.unsqueeze(0).expand_as(input_ids)                      # (bs, max_seq_length)

        word_embeddings = self.word_embeddings(input_ids)                   # (bs, max_seq_length, dim)
        position_embeddings = self.position_embeddings(position_ids)        # (bs, max_seq_length, dim)

        embeddings = word_embeddings + position_embeddings  # (bs, max_seq_length, dim)
        embeddings = self.LayerNorm(embeddings)             # (bs, max_seq_length, dim)
        embeddings = self.dropout(embeddings)               # (bs, max_seq_length, dim)
        return embeddings
def forward ( self , input_ids ) : seq_length = input_ids . size ( 1 ) position_ids = torch . arange ( seq_length , dtype = torch . long , device = input_ids . device ) # (max_seq_length) position_ids = position_ids . unsqueeze ( 0 ) . expand_as ( input_ids ) # (bs, max_seq_length) word_embeddings = self . word_embeddings ( input_ids ) # (bs, max_seq_length, dim) position_embeddings = self . position_embeddings ( position_ids ) # (bs, max_seq_length, dim) embeddings = word_embeddings + position_embeddings # (bs, max_seq_length, dim) embeddings = self . LayerNorm ( embeddings ) # (bs, max_seq_length, dim) embeddings = self . dropout ( embeddings ) # (bs, max_seq_length, dim) return embeddings