If you define a (static) backward function, you can print there.
For checking what’s going on with predefined functions, hooks would be the usual choice
    x = torch.tensor([[1.,2.], [3.,4.], [5.,6.]], dtype=torch.float, requires_grad=True)
    y = torch.var(x)
    def get_hook(name):
        def my_hook(g):
            print ("hook for",name,"grad",g)
        return my_hook
    y.register_hook(get_hook("y"))
    x.register_hook(get_hook("x"))
    y.backward(torch.randn(y.size())) 

I’m afraid there is only so much advice to offer when you don’t have an example that shows more about what you try to achieve.
Best regards
Thomas