# sequence_scatter¶

api_attr

Static Graph

Note:

The index and updates parameters of the OP must be LoDTensor.

Plus the updates data to the corresponding input according to the index.

The updated algorithm is as follows: output[instance_index][index [pos]] = input[instance_index][index [pos]] + updates[pos], where instance_idx is the K sample corresponding to pos in batch.

The value of output[i][j] depends on whether j can be found in the i+1th interval of the index. If found, out[i][j] = input[i][j] + update[m] [n], otherwise, out[i][j] = input[i][j].

For example, in the following example, the lod information for index is divided into three sequences. Among them, because the element 0 can be found in the first interval of the index, it is updated with the value of the corresponding position of the updates, out = input+updates . Because element 1 cannot be found in the third interval of index, out = input.

```*Case 1:

Given:
input.data = [[1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
[1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
[1.0, 1.0, 1.0, 1.0, 1.0, 1.0]]
input.dims = [3, 6]

index.data = [, , , , , , , , , , , ]
index.lod =  [[0,        3,                       8,                 12]]

updates.data = [[0.3], [0.3], [0.4], [0.1], [0.2], [0.3], [0.4], [0.0], [0.2], [0.3], [0.1], [0.4]]
updates.lod =  [[  0,            3,                                 8,                         12]]

Then:
out.data = [[1.3, 1.3, 1.4, 1.0, 1.0, 1.0],
[1.0, 1.0, 1.4, 1.3, 1.2, 1.1],
[1.0, 1.0, 1.3, 1.2, 1.4, 1.1]]
out.dims = X.dims = [3, 6]
```
Parameters
• input (Variable) – A Tensor with shape of \([N, k_1... k_n]\). Supported data types: float32, float64, int32, int64.

• index (Variable) – A LoDTensor contains index information. Its LoD level must be 1 and its data type can be int32 or int64.

• updates (Variable) – A LodTensor contains updates information. It has the same LoD level with the index and has the same data type with the input. Supported data types: float32, float64, int32, int64.

• name (str, optional) – The default value is None. Normally there is no need for user to set this property. For more information, please refer to Name

Returns

A Tensor which has been updated. It has the same shape and data type with input.

Return type

Variable

Examples

```import paddle