def bezier_sample(t, params):
    """Sample points from cubic Bezier curves defined by params at t values."""
    A = params.new_tensor([[1, 0, 0, 0],
                           [-3, 3, 0, 0],
                           [3, -6, 3, 0],
                           [-1, 3, -3, 1]])

    t = t.pow(t.new_tensor([0, 1, 2, 3]))  # [n_samples, 4]

    points = t @ A @ params  # [..., n_samples, 3]
    return points