How to merge multiple autograd::Function or nest them?

Let us say we write something like:

struct my_func : torch::autograd::Function<my_func> {}

I can write my own forward() and backward() and in my main module I can use my_func::apply() to use this function.

My question is, how can create multiple autograd::Function and combine them (pass gradients between and invoke them from my main nn::Module inheriting struct)?

You should be able to directly use the function in your custom modules and Autograd will be able to compute the gradients as your custom backward function is also defined.
Let me know, if I misunderstand your use case.

Well, in my use case, one autograd::Function has to run a parallel_for loop and call a second autograd::Function in each iteration. How to invoke the second Function? Still using apply()? How will the forward() and backward() handled in this case? Is it possible to provide an example?

I need to understand the syntax, since, the documentation is extremely scant for the cpp frontend.