Hi @mayool,
I think that the answer is: it depends (as usual).

The first code assumes you have one class: “1”. If you calculate the IoU score manually you have: 3 "1"s in the right position and 4 "1"s in the union of both matrices: 3/4 = 0.7500.
If you consider that you have two classes: “1” and “0”. We know already that “1” has an IoU score of 0.7500. Considering only "0"s, you have 5 "0"s correctly predicted, and 6 “0s” in the union: 5/6 = 0.8333.

Also, your code seems to have mistaken the input order of _fast_hist, it should be hist = _fast_hist(true, pred, num_classes=2) (notice pred and true are not in the right order), but it gave the right answer anyway.
So, for question 1: 0.7500 is the IoU for class “1” and 0.8333 is the IoU for class “0”. 0.7971 is just the average of both.
The purpouse of EPS (yes, epsilon) is to avoid division by zero. I think that case is possible only if your class is not present in any of the matrices, but is not bad to have it. Also, the epsilon value is so small that it should not modify your values in a significant way.