Solved by googlebot in post #2 
              
              
                torch.where(b < len(a), a[b.clamp_max(len(a)-1)], torch.tensor([-1]))

true “lazy” ops have “masked” in their names, but there is no “masked_gather” I think.