def _embed(self, document: str, features: np.ndarray) -> np.ndarray:
        """Mean pooling.

        Arguments:
            document: The document for which to extract the attention mask
            features: The embeddings for each token

        Adopted from:
        https://huggingface.co/sentence-transformers/all-MiniLM-L12-v2#usage-huggingface-transformers
        """
        token_embeddings = np.array(features)
        attention_mask = self.embedding_model.tokenizer(document, truncation=True, padding=True, return_tensors="np")[
            "attention_mask"
        ]
        input_mask_expanded = np.broadcast_to(np.expand_dims(attention_mask, -1), token_embeddings.shape)
        sum_embeddings = np.sum(token_embeddings * input_mask_expanded, 1)
        sum_mask = np.clip(
            input_mask_expanded.sum(1),
            a_min=1e-9,
            a_max=input_mask_expanded.sum(1).max(),
        )
        embedding = normalize(sum_embeddings / sum_mask)[0]
        return embedding
Mean pooling.

        Arguments:
            document: The document for which to extract the attention mask
            features: The embeddings for each token

        Adopted from:
        https://huggingface.co/sentence-transformers/all-MiniLM-L12-v2#usage-huggingface-transformers
        
bertopic/backend/_hftransformers.py