torch.trapezoid
torch.trapezoid(y, x=None, *, dx=None, dim=- 1) -> Tensor
Computes the trapezoidal rule along "dim". By default the spacing
   between elements is assumed to be 1, but "dx" can be used to
   specify a different constant spacing, and "x" can be used to
   specify arbitrary spacing along "dim".
Assuming "y" is a one-dimensional tensor with elements {y_0, y_1,
   ..., y_n}, the default computation is
  \begin{aligned}     \sum_{i = 1}^{n-1} \frac{1}{2} (y_i +
  y_{i-1}) \end{aligned}

When "dx" is specified the computation becomes
  \begin{aligned}     \sum_{i = 1}^{n-1} \frac{\Delta x}{2} (y_i +
  y_{i-1}) \end{aligned}

effectively multiplying the result by "dx". When "x" is specified,
   assuming "x" is also a one-dimensional tensor with elements {x_0,
   x_1, ..., x_n}, the computation becomes
  \begin{aligned}     \sum_{i = 1}^{n-1} \frac{(x_i - x_{i-1})}{2}
  (y_i + y_{i-1}) \end{aligned}
