I had a question. In general, what’s the best way to test if autograd works with certain external packages? That is, the gradient is being properly calculated…

In general, if a package is not using torch.Tensor, then it cannot be supported by autograd. So mathutils in this case won’t work as I don’t think you can give torch.Tensors as input.
Note that if you really need such function, you can always use it and use a custom autograd Function (doc here Extending PyTorch — PyTorch 1.9.0 documentation) to teach the autograd what is the backward pass for it. That way you will be able to use it within pytorch autograd.