    def generate_square_subsequent_mask(self, sz):
        """Generate a square mask for the sequence. The masked positions are filled with float('-inf').
            Unmasked positions are filled with float(0.0).
        """
        mask = torch.zeros([sz, sz], dtype=torch.float32)
        mask_inf = torch.triu(
            torch.full(
                size=[sz, sz], fill_value=float('-Inf'),  dtype=torch.float32),
            diagonal=1)
        mask = mask + mask_inf
        return mask
Generate a square mask for the sequence. The masked positions are filled with float('-inf').
Unmasked positions are filled with float(0.0).
pytorchocr/modeling/heads/rec_nrtr_head.py