Solved by KFrank in post #4 
              
              
                Hi Xianqian! 

cumprod() – for boolean values – will test for “decreasing values”: 
>>> import torch
>>> torch.__version__
'1.9.0'
>>>
>>> b1 = torch.tensor ([
...     [True,  False, False, False],
...     [False, False, False, False],
...     [True,  True,  False, False],
...     [True,  True,  Tru…