If I have two 3-D tensors `img` and `gen`. How do I assign a 2D subset of `img` with a 2D subset of `gen`? The following doesn't work as tensorflow doesn't allow direct assignment of tensors.

```
img[96:160 , 144:240 , :] = gen[96:160 , 144:240 , :]

```

**EDIT:**

This is the surrounding code. So I'm using a custom keras layer. This layer must receive the input image `img` and the generated image `x`. It must replace a portion of `img` with `x` and must return the modified `img`.

```
def patcher(tensors):
    img = tensor[1]
    gen = tensor[0]
    #This is where the slicing must happen
    img[96:160 , 144:240 , :] = gen[96:160 , 144:240 , :]
    return [img]

img = Input( .. )
x = Conv( .. )(img)
out = Lambda(patcher,lambda a : [a[1]] )([x , img])
model = Model(img, out)

```