    def pad4group(self, Q, K, V, P, mask, group_size: int = 3):
        """
        q: (#batch, time1, size) -> (#batch, head, time1, size/head)
        k,v: (#batch, time2, size) -> (#batch, head, time2, size/head)
        p: (#batch, time2, size)
        """
        # Compute Overflows
        overflow_Q = Q.size(2) % group_size
        overflow_KV = K.size(2) % group_size

        # if-else for ONNX export
        #   0 // 0.00000000000000001 = 0
        #   1 // 1.00000000000000001 = 1
        padding_Q = (group_size - overflow_Q) * int(
            overflow_Q // (overflow_Q + 0.00000000000000001)
        )
        padding_KV = (group_size - overflow_KV) * int(
            overflow_KV // (overflow_KV + 0.00000000000000001)
        )

        batch_size, _, seq_len_KV, _ = K.size()

        # Input Padding (B, T, D) -> (B, T + P, D)
        Q = F.pad(Q, (0, 0, 0, padding_Q), value=0.0)
        K = F.pad(K, (0, 0, 0, padding_KV), value=0.0)
        V = F.pad(V, (0, 0, 0, padding_KV), value=0.0)

        if mask is not None and mask.size(2) > 0:  # time2 > 0:
            mask = mask[:, ::group_size, ::group_size]

        Q = (
            Q.transpose(1, 2)
            .contiguous()
            .view(batch_size, -1, self.h, self.d_k * group_size)
            .transpose(1, 2)
        )
        K = (
            K.transpose(1, 2)
            .contiguous()
            .view(batch_size, -1, self.h, self.d_k * group_size)
            .transpose(1, 2)
        )
        V = (
            V.transpose(1, 2)
            .contiguous()
            .view(batch_size, -1, self.h, self.d_k * group_size)
            .transpose(1, 2)
        )

        # process pos_emb
        P_batch_size = P.size(0)
        overflow_P = P.size(1) % group_size
        padding_P = group_size - overflow_P if overflow_P else 0
        P = F.pad(P, (0, 0, 0, padding_P), value=0.0)
        P = P.view(P_batch_size, -1, self.h, self.d_k * group_size).transpose(1, 2)

        return Q, K, V, P, mask, padding_Q
q: (#batch, time1, size) -> (#batch, head, time1, size/head)
k,v: (#batch, time2, size) -> (#batch, head, time2, size/head)
p: (#batch, time2, size)
modules/wenet_extractor/efficient_conformer/attention.py