I wonder if it would be possible to take optional grad and infer_shape arguments.