The fancy way PyTorch offers for this is parametrizations, but I think for positive you still need to roll your own transformation (but it could be easy with exp or softplus or so).
https://pytorch.org/docs/stable/generated/torch.nn.utils.parametrize.register_parametrization.html?highlight=parametrization#torch.nn.utils.parametrize.register_parametrization
Best regards
Thomas