Could someone please explain why x_hv and y_hv  are being multiplied by 5 and 4, respectively?

  
      github.com
  
  
    pytorch/pytorch/blob/master/test/test_autograd.py#L179 13

        return x_grad, x_grad_clone


    # Accumulate in-place when create_graph is False
    x_grad, x_grad_clone = compute_grad(create_graph=False)
    self.assertEqual(x_grad, x_grad_clone * 2)


    # Accumulate out-of-place when create_graph is False
    x_grad, x_grad_clone = compute_grad(create_graph=True)
    self.assertEqual(x_grad, x_grad_clone)


def test_hessian_vector(self):
    x = Variable(torch.randn(2, 2), requires_grad=True)
    y = Variable(torch.randn(2, 2), requires_grad=True)


    z = x ** 2 + y * x + y ** 2
    z.backward(torch.ones(2, 2), create_graph=True)


    x_grad = 2 * x.data + y.data
    y_grad = x.data + 2 * y.data
    self.assertEqual(x.grad.data, x_grad)
    self.assertEqual(y.grad.data, y_grad)



  
  
    
    
  
  


 def test_hessian_vector(self):
    x = Variable(torch.randn(2, 2), requires_grad=True)
    y = Variable(torch.randn(2, 2), requires_grad=True)

    z = x ** 2 + y * x + y ** 2
    z.backward(torch.ones(2, 2), create_graph=True)

    x_grad = 2 * x.data + y.data
    y_grad = x.data + 2 * y.data
    self.assertEqual(x.grad.data, x_grad)
    self.assertEqual(y.grad.data, y_grad)

    grad_sum = 2 * x.grad + y.grad
    grad_sum.backward(torch.ones(2, 2))
    x_hv = torch.ones(2, 2) * 5
    y_hv = torch.ones(2, 2) * 4
    self.assertEqual(x.grad.data, x_grad + x_hv)
    self.assertEqual(y.grad.data, y_grad + y_hv)

Could someone please explain why x_hv and y_hv  are being multiplied by 5 and 4, respectively?