@mikehamer Thanks a lot for sharing your code. I tried your code with the libtorch 1.4 version, it works great with few changes:

auto result = as_variable(tmp); need to be changed to auto result = tmp; since as_variable is no longer available.
deleteFunction and Function need to be replaced with deleteNode and Node.