Hello,

I have 2D tensors, where each row starts with `1`

and continues with a variable length of `1`

s followed by `0`

s.

I want to turn the first and the last `1`

of each row to `0`

.

For instance, for a tensor with `torch.Size([3, 7])`

, that initially is

```
tensor([[1, 1, 1, 1, 0, 0, 0],
[1, 1, 1, 0, 0, 0, 0],
[1, 1, 1, 1, 1, 0, 0]])
```

and I want to transform it to the tensor

```
tensor([[0, 1, 1, 0, 0, 0, 0],
[0, 1, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 0, 0, 0]])
```

What is the most straight forward way to make this transformation?