def set_pretrained_embeddings(self, embedding_matrix):
        """Set embedding weights.

        Args:
            embedding_matrix(torch.Tensor): Embedding matrix.

        """
        if embedding_matrix.shape[0] != self.src_embedding.weight.size(
            0
        ) or embedding_matrix.shape[1] != self.src_embedding.weight.size(1):
            logging.info(
                """
                Warning pretrained embedding shape mismatch %d x %d
                expected %d x %d"""
                % (
                    embedding_matrix.shape[0],
                    embedding_matrix.shape[1],
                    self.src_embedding.weight.size(0),
                    self.src_embedding.weight.size(1),
                )
            )
            self.src_embedding = nn.Embedding(
                embedding_matrix.shape[0], embedding_matrix.shape[1]
            )
            self.src_vocab_size = embedding_matrix.shape[0]
            self.src_emb_dim = embedding_matrix.shape[1]

        try:
            self.src_embedding.weight.data.set_(
                torch.from_numpy(embedding_matrix)
            )
        except BaseException:
            self.src_embedding.weight.data.set_(
                torch.from_numpy(embedding_matrix).cuda()
            )

        self.src_embedding.cuda()
Set embedding weights.

        Args:
            embedding_matrix(torch.Tensor): Embedding matrix.

        
utils_nlp/models/gensen/gensen.py