def loss(self, feats: torch.Tensor, target: torch.Tensor,
             mask: torch.Tensor) -> torch.Tensor:
        """Generate loss.

        Args:
            feats (torch.Tensor): Features from backbone.
            target (torch.Tensor): Target generated by target_generator.
            mask (torch.Tensor): Generated mask for pretraing.
        """
        mask = mask.flatten(1).to(torch.bool)
        target = torch.argmax(target, dim=1).flatten(1)
        target = target[mask]

        # remove cls_token
        feats = feats[:, 1:]
        logits = self.cls_head(feats[mask])

        loss = self.loss_module(logits, target)
        return loss
Generate loss.

        Args:
            feats (torch.Tensor): Features from backbone.
            target (torch.Tensor): Target generated by target_generator.
            mask (torch.Tensor): Generated mask for pretraing.
        
mmpretrain/models/heads/beitv1_head.py