Changed produceRandomGradOutput to handle number outputs correctly

Enables some modules to be tested that previously failed