If you’re tired to the point that you can’t retain any new information, it’s better to take a break and try later when you’re rested.
If I’m really determined to be productive I’ll do simple tasks that don’t require thinking, like making flashcards to use for later or writing out loose ideas and paragraphs that I’ll edit another time.
Generally no, but I've found one exception: the feeling of overcoming a difficult problem at 4am will give you a sound and satisfying sleep like no other in existence.
Then you wake up and forget how you solved it. Time to begin again!
It will make you angry and frustrated, if that's what you're looking for. Probably doesn't help with learning at all, quite the contrary. If you're interested and engaged with the material, you can learn so much faster. If you hate what you're doing, there will be very little progress, if any. Take a nap, and look at the material with fresh eyes when you feel better.
There can also be something I call "mental inertia". Occasionally, it's difficult to get started. That's when a short warmup can help. Start with something easy, to get in the right mood. After that, you can tackle some of the harder problems.
You need a strategy to reach your goals, and it should include getting enough sleep. Neglecting it will not help with your goals, unless one of them is to be as miserable as possible.
For me, any kind of cramming gave me short term gains, but I didn't remember long term.
That said, past the point of exhaustion, I was too tired for the test the next day anyway.
The best thing to do is cram the same day as the test, up until the very minute the test starts.
But if you do this, you won't remember the material after the test ends. If you want to actually learn it, you have to take care of your body and mind first.
Feels like even worse than a waste of time to me, like an actual negative where your half formed memories interfere with actual recall.
Especially if you're cramming the night before. A good sleep will always get you a better result, and if you're desperate because you're completely unprepared the lesson to learn is don't do that again.
You'll know your body best, but it does take quite some effort to take in and process information.
On very tired days I typically only review my notes (to keep up the SRS) and/or do some admin. Also I try to make sure it's not only studies having to compromise when my energy is flagging.