implement batch entropy in python