tensor([6., 21.])
  >>> # Cumulatively computes the trapezoidal rule in 1D with arbitrary spacing
  >>> x = torch.tensor([1, 3, 6])
  >>> torch.cumulative_trapezoid(y, x)
  tensor([6., 28.5])

  >>> # Computes the same trapezoidal rule directly up to each element to verify
  >>> ((3 - 1) * (1 + 5)) / 2
  6.0
  >>> ((3 - 1) * (1 + 5) + (6 - 3) * (5 + 10)) / 2
  28.5

  >>> # Cumulatively computes the trapezoidal rule for each row of a 3x3 matrix
  >>> y = torch.arange(9).reshape(3, 3)
  tensor([[0, 1, 2],
          [3, 4, 5],
          [6, 7, 8]])
  >>> torch.cumulative_trapezoid(y)
  tensor([[ 0.5,  2.],
          [ 3.5,  8.],
          [ 6.5, 14.]])

  >>> # Cumulatively computes the trapezoidal rule for each column of the matrix
  >>> torch.cumulative_trapezoid(y, dim=0)
  tensor([[ 1.5,  2.5,  3.5],
          [ 6.0,  8.0, 10.0]])
