Solved by LeviViana in post #2 
              
              
                I don’t think that there is an exact equivalent. But here is a workaround: 
PS: this example is the same exposed in the link you provided. 
import torch
x = torch.Tensor([
                  [[1, 0, 0, 0],
                   [0, 2, 0, 0],
                   [0, 0, 3, 0],
                   [0, 0, 0, …