I developed a reputation for this since the first year of secondary school because I've done this hundreds of times; people knew I slept everywhere. Sometimes I am sleep-deprived, but other times the teacher just goes on and on and on like Fiora told them to without giving me any chance of interaction to wake my inactive body (which is just sitting and listening), so I just nod off due to inactivity. I don't think teachers understand my perspective though.
I don't think I've ever gotten in real trouble for it though, despite the high-ranking status of some of the staff (head of year actually banters with me about this) who have seen me do it and instead they just poke fun at me or believe I still take in what they're teaching when I'm conked out. Their passive response is probably because I could probably teach myself whatever I'm missing or have the independence to ask about it later, don't really cause trouble and I never just give into the sleeping urges (I try to stay awake as long as possible under the thoughts of 'I like this teacher I must show respect'), so they probably just feel bad because I can't help it.
When I try to sleep in class, it never works though. I never fall asleep. But I kid you not; any part of my secondary school life, I have dozed off during. During performances, during assemblies, even during PE: if I'm tired or have to idle for ages, it's an inevitable occurrence.
Sometimes it's the briefest siesta (literally seconds), others it's minutes, and occasionally it can be the whole lesson or whatever it is.