def METHOD_NAME(
    self,
    mode,
    features,
    infos,
    records,
    **kwargs,
):
    if mode in ["train", "valid"]:
        features = torch.stack(features)
        prefix_sums, labels = infos
        labels = torch.cat(labels).to(features.device)
        embs = self.model(features)
        query_embs = embs[: self.datarc["batch_size"]]
        audio_embs = embs[self.datarc["batch_size"] :]
        max_similarities = torch.empty(len(labels)).to(labels.device)
        for i in range(self.datarc["batch_size"]):
            similarities = F.cosine_similarity(
                query_embs[i : i + 1],
                audio_embs[prefix_sums[i] : prefix_sums[i + 1]],
            )
            max_similarities[i] = similarities.max()
        # cosine embedding loss
        pos_similarities = max_similarities[labels > 0]
        neg_similarities = max_similarities[labels < 0]
        pos_loss = (1 - pos_similarities).sum()
        neg_loss = neg_similarities.clamp(0).sum()
        loss = (pos_loss + neg_loss) / self.datarc["batch_size"]
        # record information
        records["loss"].append(loss.item())
        records["similarity-positive"] += pos_similarities.tolist()
        records["similarity-negative"] += neg_similarities.tolist()
        return loss
    elif mode in ["dev", "eval"]:
        audio_tensors = torch.stack(features)
        prefix_sums, audio_names = infos
        embs = self.model(audio_tensors)
        embs = embs.detach().cpu()
        for i in range(len(audio_names)):
            records["embs"].append(embs[prefix_sums[i] : prefix_sums[i + 1]])
            records["audio_names"].append(audio_names[i])
    else:
        raise NotImplementedError