def METHOD_NAME(self, input_ids, token_type_ids=None, position_ids=None):
    src_mask = input_ids == self.bos_id
    src_mask = paddle.cast(src_mask, "float32")
    # [bs, 1, 1, max_len]
    src_mask = paddle.unsqueeze(src_mask, axis=[1, 2])
    src_mask.stop_gradient = True
    ones = paddle.ones_like(input_ids, dtype="int64")
    seq_length = paddle.cumsum(ones, axis=1)
    position_ids = seq_length - ones
    position_ids.stop_gradient = True
    embedding_output = self.ptm.embeddings(
        input_ids=input_ids, position_ids=position_ids, token_type_ids=token_type_ids
    )
    if self.use_fp16:
        embedding_output = paddle.cast(embedding_output, "float16")
    sequence_output = self.ptm.encoder(embedding_output, src_mask)
    if self.use_fp16:
        sequence_output = paddle.cast(sequence_output, "float32")
    cls_embedding = self.ptm.pooler(sequence_output)
    if self.output_emb_size > 0:
        cls_embedding = self.emb_reduce_linear(cls_embedding)
    cls_embedding = self.dropout(cls_embedding)
    cls_embedding = F.normalize(cls_embedding, p=2, axis=-1)
    return cls_embedding