As others have said, don't let them flatten you out in the first place.
But when i am flattened out, i place my right arm flush on the mat (palm down and arm bent at 90 degree angle) and bring my right knee up to my right elbow. I then bring my left knee up to my left elbow. You have to keep your body very compact when doing this. Now i am on my knees (turtle position). Much better place to be than being flattened out. (Practice by yourself without a partner first and then practice with someone on your back. You can even do this versus someone very heavy once you get good at it)
From here you can look to stand up (basic standup wrestling escape from turtle position). If they don't have both hooks or body triangle, you may be able to hit a Granby roll, a sit out or a switch...these are all common wrestling escapes/reversals.
If they do have their hooks in or body triangle, those wrestling techniques may not work because they can follow your body and ride your back, because of their legs. At this point, you will have to look for a more traditional BJJ back escape. (Millions of videos available for that)
But the whole key for me at least, is once flattened, I must get back to my knees (turtle position) ASAP.