def interpolate1d(x, values, tangents):
    'Perform cubic hermite spline interpolation on a 1D spline.\n\n  The x coordinates of the spline knots are at [0 : 1 : len(values)-1].\n  Queries outside of the range of the spline are computed using linear\n  extrapolation. See https://en.wikipedia.org/wiki/Cubic_Hermite_spline\n  for details, where "x" corresponds to `x`, "p" corresponds to `values`, and\n  "m" corresponds to `tangents`.\n\n  Args:\n    x: A tensor of any size of single or double precision floats containing the\n      set of values to be used for interpolation into the spline.\n    values: A vector of single or double precision floats containing the value\n      of each knot of the spline being interpolated into. Must be the same\n      length as `tangents` and the same type as `x`.\n    tangents: A vector of single or double precision floats containing the\n      tangent (derivative) of each knot of the spline being interpolated into.\n      Must be the same length as `values` and the same type as `x`.\n\n  Returns:\n    The result of interpolating along the spline defined by `values`, and\n    `tangents`, using `x` as the query values. Will be the same length and type\n    as `x`.\n  '
    assert torch.is_tensor(x)
    assert torch.is_tensor(values)
    assert torch.is_tensor(tangents)
    float_dtype = x.dtype
    assert (values.dtype == float_dtype)
    assert (tangents.dtype == float_dtype)
    assert (len(values.shape) == 1)
    assert (len(tangents.shape) == 1)
    assert (values.shape[0] == tangents.shape[0])
    x_lo = torch.floor(torch.clamp(x, torch.as_tensor(0), (values.shape[0] - 2))).type(torch.int64)
    x_hi = (x_lo + 1)
    t = (x - x_lo.type(float_dtype))
    t_sq = (t ** 2)
    t_cu = (t * t_sq)
    h01 = (((- 2.0) * t_cu) + (3.0 * t_sq))
    h00 = (1.0 - h01)
    h11 = (t_cu - t_sq)
    h10 = ((h11 - t_sq) + t)
    value_before = ((tangents[0] * t) + values[0])
    value_after = ((tangents[(- 1)] * (t - 1.0)) + values[(- 1)])
    neighbor_values_lo = values[x_lo]
    neighbor_values_hi = values[x_hi]
    neighbor_tangents_lo = tangents[x_lo]
    neighbor_tangents_hi = tangents[x_hi]
    value_mid = ((((neighbor_values_lo * h00) + (neighbor_values_hi * h01)) + (neighbor_tangents_lo * h10)) + (neighbor_tangents_hi * h11))
    return torch.where((t < 0.0), value_before, torch.where((t > 1.0), value_after, value_mid))
Perform cubic hermite spline interpolation on a 1D spline.

The x coordinates of the spline knots are at [0 : 1 : len(values)-1].
Queries outside of the range of the spline are computed using linear
extrapolation. See https://en.wikipedia.org/wiki/Cubic_Hermite_spline
for details, where "x" corresponds to `x`, "p" corresponds to `values`, and
"m" corresponds to `tangents`.

Args:
  x: A tensor of any size of single or double precision floats containing the
    set of values to be used for interpolation into the spline.
  values: A vector of single or double precision floats containing the value
    of each knot of the spline being interpolated into. Must be the same
    length as `tangents` and the same type as `x`.
  tangents: A vector of single or double precision floats containing the
    tangent (derivative) of each knot of the spline being interpolated into.
    Must be the same length as `values` and the same type as `x`.

Returns:
  The result of interpolating along the spline defined by `values`, and
  `tangents`, using `x` as the query values. Will be the same length and type
  as `x`.
def interpolate1d(x, values, tangents):
    'Perform cubic hermite spline interpolation on a 1D spline.\n\n  The x coordinates of the spline knots are at [0 : 1 : len(values)-1].\n  Queries outside of the range of the spline are computed using linear\n  extrapolation. See https://en.wikipedia.org/wiki/Cubic_Hermite_spline\n  for details, where "x" corresponds to `x`, "p" corresponds to `values`, and\n  "m" corresponds to `tangents`.\n\n  Args:\n    x: A tensor of any size of single or double precision floats containing the\n      set of values to be used for interpolation into the spline.\n    values: A vector of single or double precision floats containing the value\n      of each knot of the spline being interpolated into. Must be the same\n      length as `tangents` and the same type as `x`.\n    tangents: A vector of single or double precision floats containing the\n      tangent (derivative) of each knot of the spline being interpolated into.\n      Must be the same length as `values` and the same type as `x`.\n\n  Returns:\n    The result of interpolating along the spline defined by `values`, and\n    `tangents`, using `x` as the query values. Will be the same length and type\n    as `x`.\n  '
    assert torch.is_tensor(x)
    assert torch.is_tensor(values)
    assert torch.is_tensor(tangents)
    float_dtype = x.dtype
    assert (values.dtype == float_dtype)
    assert (tangents.dtype == float_dtype)
    assert (len(values.shape) == 1)
    assert (len(tangents.shape) == 1)
    assert (values.shape[0] == tangents.shape[0])
    x_lo = torch.floor(torch.clamp(x, torch.as_tensor(0), (values.shape[0] - 2))).type(torch.int64)
    x_hi = (x_lo + 1)
    t = (x - x_lo.type(float_dtype))
    t_sq = (t ** 2)
    t_cu = (t * t_sq)
    h01 = (((- 2.0) * t_cu) + (3.0 * t_sq))
    h00 = (1.0 - h01)
    h11 = (t_cu - t_sq)
    h10 = ((h11 - t_sq) + t)
    value_before = ((tangents[0] * t) + values[0])
    value_after = ((tangents[(- 1)] * (t - 1.0)) + values[(- 1)])
    neighbor_values_lo = values[x_lo]
    neighbor_values_hi = values[x_hi]
    neighbor_tangents_lo = tangents[x_lo]
    neighbor_tangents_hi = tangents[x_hi]
    value_mid = ((((neighbor_values_lo * h00) + (neighbor_values_hi * h01)) + (neighbor_tangents_lo * h10)) + (neighbor_tangents_hi * h11))
    return torch.where((t < 0.0), value_before, torch.where((t > 1.0), value_after, value_mid))