Device with Multiple Switches

Hi, is there any way to sync between the physical switch state to virtual switch?
I have the situation like this: I turn off the virtual switch by alexa, later, I turn on physical switch. after that, If I use Alexa to turn off the virtual switch, it says ok but didn’t do anything because the virtual switch is off already.
I have read another post that can sync two switches but it not for multiples switches device:

I’m don’t know about this coding language so I don’t know if it can be use here.