This works:
>>> import torch
>>> a = torch.rand(2, 3, 4)
>>> print(a)
tensor([[[0.5066, 0.5184, 0.1193, 0.6062],
         [0.4995, 0.1689, 0.6175, 0.7917],
         [0.7996, 0.0225, 0.1145, 0.4249]],

        [[0.0975, 0.2995, 0.5857, 0.0806],
         [0.4922, 0.4778, 0.9133, 0.1418],
         [0.6594, 0.4907, 0.3268, 0.1211]]])
>>> l = torch.randint(3, (2, ))
>>> print(l)
tensor([1, 2])
>>> l += torch.arange(2) * 3
>>> b = torch.arange(6).view(2, 3)
>>> b = b < l.view(2, 1)
>>> a * b.view(2, 3, 1).float()
tensor([[[0.5066, 0.5184, 0.1193, 0.6062],
         [0.0000, 0.0000, 0.0000, 0.0000],
         [0.0000, 0.0000, 0.0000, 0.0000]],

        [[0.0975, 0.2995, 0.5857, 0.0806],
         [0.4922, 0.4778, 0.9133, 0.1418],
         [0.0000, 0.0000, 0.0000, 0.0000]]])
>>> 

I hope it helps !