def mean_pooling(token_embeddings: FloatTensor, attention_mask: FloatTensor) -> FloatTensor:
        """performs mean average pooling over a matrix with a supplied attention mask

        Args:
            token_embeddings (FloatTensor): _description_
            attention_mask (FloatTensor): _description_

        Returns:
            FloatTensor: _description_
        """
        input_mask_expanded = attention_mask.unsqueeze(-1).expand(token_embeddings.size()).float()

        return torch.sum(token_embeddings * input_mask_expanded, 1) / torch.clamp(input_mask_expanded.sum(1), min=1e-9)
performs mean average pooling over a matrix with a supplied attention mask

        Args:
            token_embeddings (FloatTensor): _description_
            attention_mask (FloatTensor): _description_

        Returns:
            FloatTensor: _description_
        
src/marqo/s2_inference/sbert_onnx_utils.py