How to add a new parameter which is derived from output of the previous layer of the neural network model

How to add a new parameter which is derived from output of the previous layer, apart from weights and baises in Custom layer of the neural network model.
I want the ouput of previous layer rolled(torch.roll) by 1 position and use this new parameter in the Custom Layer after it.

Note that the output of a layer would not be a parameter, as it’s not a leaf tensor because it was calculated from another parameter.
In any case, you could try to assign the output of the previous layer to the parameter attributes of the next layer but should note that this custom layer will not be trained by the optimizer anymore.

How can i use CVXPY(Convex Optimization) layer as cutsom layer inside Deep Neural networks in Pytorch?

I don’t know how this layer is defined, but assuming it’s derived from nn.Module you should be able to directly use it as any other layer.