Ho ok !
I that case I would recommend the following so that it actually still builds the backward graph for you to properly simulate what you want:
class Zeros(nn.Module):
    def __init__(self, num_predict: int):
        super().__init__()
        # Need at least one trainable parameter in the model
        self.par = nn.Parameter(torch.rand(1, num_predict))

    def forward(self, batch: Tensor) -> Tensor:
        return self.par.expand(batch.size(0), -1) * batch.sum() * 0.

Happy to look at your example when you have it !