$12$ Prisoner Hat Problem with $5$ different Hats There are $12$ prisoners named $A,B,C,D,E,F,G,H,I,J,K$ and $L$ and each of them was given a hat with the number $0,1,2,3$ or $4$ on it. They cannot see what is on their own hat but can see what is on the other $11$ prisoners' hats. 

The guard calls them forward in alphabetical order and asks them to whisper in his ear what number they think is on their hat. If they are correct they are allowed to leave otherwise they get executed. 

Before the prisoners are given hats they are allowed to devise an optimum strategy so that the most prisoners leave with their life. Once hats are given no communication is allowed between the prisoners (including any sort of secret code). 

What is the optimum strategy and how many prisoners can survive?
According to the OP's comments, later prisoners can observe the fate of earlier prisoners. But now it's easy to ensure that at least eight prisoners survive:

$A,B,C,$ and $D$ assume that the sum of all the hats modulo $5$ is equal to $0,1,2,$ and $3$ respectively, and base their answer on this assumption. As soon as one of them goes free, everybody else knows this sum, so they can answer correctly.

If none of them go free, the sum must be $4$. And of course if $A,B,$ or $C$ goes free, then $B,C,$ and/or $D$ are freed from their obligations, and will go free too. So the number of survivors can be anything from $8$ to $12$.
The probability of a prisoner guessing his hat number is $\frac{1}{5}$

The probability of a prisoner not guessing his hat number is $\frac{4}{5}$.

In other words, the prisoner knowing other prisoner's hat number has no bearing on his guessing his hat number correctly.  Each prisoner guesses independently of other prisoners.

P ( all guessed correctly) $={12\choose12} \frac{4^0}{5^{12}}$

P ( 11 guessed correctly) $={12\choose11} \frac{4^1}{5^{12}}$

...

P ( 0 guessed correctly) $={12\choose0} \frac{4^{12}}{5^{12}}$

This looks like binomial distribution and thus the expected number of prisoners who will survive $$\sum_{i=0}^{12} i{12\choose 12-i} \left(\frac{4}{5}\right)^{12-i} \left(\frac{1}{5}\right)^{i}$$

$$=\boxed{2.4}$$