Here is a small example:
a = torch.Tensor(
                  [[[3,4,0],[0,2,3],[1,3,0]],
                   [[1,3,0],[0,2,1],[1,2,0]],
                   [[3,3,0],[0,1,3],[1,2,0]]])

I would like to replace all pixels a[i,j,k] == [0,0,0] with randomly drawn pixels != [0,0,0] from a (with replacement).
It is important, that the three channels are not treated independently but jointly… (to keep the “colors”).
Does this clear things up?