A lot of restaurants use it as waste yield so they know how much to make the next week/day/month.

You can get in a LOT of trouble if the restaurant isn't okay with you taking it. Some are. Most aren't. One restaurant I worked at was fine if you took the leftovers of the daily special home (it only popped up once a week, so they couldn't reserve it the next day). And they counted BEFORE the servers attacked it. The other restaurant I worked at had a no-tolerance policy for such a thing. It really depends on the place.

I'm sorry, but risking my job to enjoy the last few pieces of a pie isn't worth it.