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

        Args:
            feats (torch.Tensor): Features from backbone.
            feats_cls_pt (torch.Tensor) : Features from class late layers for
                pretraining.
            target (torch.Tensor): Target generated by target_generator.
            mask (torch.Tensor): Generated mask for pretraing.
        """
        mask = mask.flatten(1).to(torch.bool)
        target = target[mask]

        # shared cls head
        logits = self.cls_head(feats[mask])
        logits_cls_pt = self.cls_head(feats_cls_pt[mask])

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

        Args:
            feats (torch.Tensor): Features from backbone.
            feats_cls_pt (torch.Tensor) : Features from class late layers for
                pretraining.
            target (torch.Tensor): Target generated by target_generator.
            mask (torch.Tensor): Generated mask for pretraing.
        
mmpretrain/models/heads/beitv2_head.py