Hello There,
There is an equivalent of this functionality in PyTorch.
https://pytorch.org/tutorials/beginner/examples_autograd/two_layer_net_custom_function.html 160
This article shows how to define a custom function with autograd tracking. You have to define the forward and backward pass of the function in a custom class inheriting torch.autograd.Function and type in ‘your_custom_function.apply’ before its usage to use it as a regular function.
Hope this helps,
All the best.