Naive Bayes

https://d2l.ai/chapter_appendix-mathematics-for-deep-learning/naive-bayes.html

np.floor(data.astype('float32') / 128)

Hello, the original shape of data is (28,28,1) and the data elements are 0/1, so I wonder why we need to /128.

And, what does this line mean for a new observation? p_xy = P_xy * x + (1 - P_xy)*(1 - x) It’s not come from a sum rule or production rule.
Thanks in advance.

My understanding is if one feature is not presented in the input data(e.g. x==0), then we also need to include its probability, which is the second term (1 - P_xy)*(1 - x)