I once had an elderly lady for a friend. She had a wonderful little dog. A mix of some sort. She had the dog trained well and it behaved very well. Learn here https://tr.im/NzvHv
She kept an uncovered candy dish on her coffee table with candy in it. The dog was forbidden to eat the candy. When she was in the room observing the dog he did not even appear to notice the candy. One day while she was in her dinning room she happened to look in a mirror and could see her dog in the living room. He did not know he was being watched. For several minutes he was sitting in front of the candy bowl staring at the candy. Finally he reached in and took one. He placed it on the table and stared at it, he woofed at it. He stared some more, licked his chops and PUT IT BACK in the bowl and walked away. Did he want the candy, oh yeah. Did he eat it? Nope. They can be trained that well but most, I'll admit, are not trained that well. When I was a young boy, maybe 5 years old. We had a german shepherd. He was very well trained also. My mom could leave food unattended on the table, no problem. She would open the oven door and set a pan roast beef or roast chicken on the door to cool. No problem. He would not touch it, watched or not. But butter? Whole other story. You leave a stick of butter anywhere he could reach and it was gone. He was a large shepherd so there were not many places he could not reach. Really, I think the number of dogs trained to the point they will leave food alone when not being supervised is very small indeed.
Now if we are talking obedience training, not food grubbing, that is a different story. Way back when I was first learning obedience training one of the final exercises was to put our dogs in a down/stay and not only leave the room but leave the building for 15 minutes. The only person that stayed was our trainer, not the owners. Most of the dogs in my class did not break their stay, which would be an automatic fail. I'm happy to report my dog was one of the ones that passed.