Sometimes you end up in a bad position like here, where the other guy has you under control in the thai clinch and is about to rain in high knees to your head and body.
Option one is to change position and regain the control of him. However if you are about to take knees, you will have to block them to buy yourself some time to switch out and throw him to the ground.
Some people say you should never try to block knees but they're the ones who normally get knocked out during clinch work. It's never going to be easy against someone with a good clinch game but it's worth training bad positions or situations so at least if it happens you have been there countless times in the gym.
You can practice the techniques below in a safe and alive fashion, I recommend you wear a gum shield and a groin cup. Some people also like to wear head protection which is fine. If you put in the hours of drilling and sparing clinch work, you actions will become instinctual and you will get out of bad positions and best of all you will have fun. I like to work three minute rounds and if I reverse the position, I place myself back in it.
Working from a bad position in thai clinch i.e. you are taking high knees, one option if you cannot change the position, is to take the knee with a double arm block (think elephant tusks) and then capture the leg and switch to throw or sweep. The nearer your block to his hips the less power you take, however you have to make sure you do not leave a gap that his knee can travel into.
Once you have control of his leg/ hip, you can unbalance, hit and or turn him into a throw. This works well with an impact weapon or blade. At any point you can switch to wrestling or counter clinch but rule one is if you have to take knees, deal with them ASAP as dents to the head or body are not fun!