Made sure that output of grad gives array of the expected size even if it's eactly zero