From the tutorial the folllowing seems to apply here :
If Tensor is a scalar (i.e. it holds a one element data), you don’t need to specify any arguments to backward() , however if it has more elements, you need to specify a gradient argument that is a tensor of matching shape.