use mode and median, notice that they don't have keepdims, so we need to make it explicit in the code