How do I get an anatz function under control?

I want to realize the function in the picture, how do I do it? Each square in the figure represents a controlled ansatz function. The controlled logic relationship can be True,True, or True,False, etc.

@CatalinaAlbornoz @Guillermo_Alonso @Maria_Schuld

Hi @RX1 , please stop tagging people in your threads. We do have other things to do sometimes. :smiley:

As I suggested in your other thread (see here: How can I use qml.select to make an overall selection of ansatz functions?), you can do this very easily if you define your ansatz function (with the 3 different options) as an operator, and then use Controlled, as you’re already trying to do (qml.ops.op_math.Controlled — PennyLane 0.32.0 documentation).
So long as your ansatz is an operator, this should work just fine. You can see the full instructions here: Adding new operators — PennyLane 0.32.0 documentation

Best of luck! :slight_smile: