I have a tensor of shape N * M * M, where N is the batch size. I want to set the diagonal of each M*M matrix to a specific number (e.g. 0). I tried fill_diagonal_ method but it doesn’t work if N!=M.
I can loop through the batch dimension, but doesn’t want to create a loop.