Optuna fforward function?

Hi, I am trying to optimize the hyperparameters of a Transformer model with optuna. Now what I am struggling with, is to figure out how i can create a forward esque object, that can returned from the trial function. As i understand it, you need to return a sequential, but I need to have skip connections and other transformations in the “sequential” object, do any of you know if this is possible, and if so how you do it?