def update_1d_tensor(F, y, index, value):
    """Updates 1d tensor y so that y[index] = value.

    Args:
      y: 1-D Tensor.
      index: index of y to modify.
      value: new value to write at y[index].

    Returns:
      y_mod: 1-D Tensor. Tensor y after the update.
    """
    value = value.squeeze()

    o = F.one_hot(index, y.size).squeeze()
    r = y * (1 - o)
    return r + (o * value)