Solved by ptrblck in post #2 
              
              
                You could just compare each index to a torch.arange tensor: 
b = torch.arange(7).unsqueeze(0) >= index.unsqueeze(1)
b = b.float()