- length = min(length, 1+torch.randint(length*2, (1,)).item())
+
+ # We take length itself half of the time, and uniform between 1
+ # and length otherwise. The actual length can be slightly greater
+
+ length = min(length, 1 + torch.randint(length * 2, (1,)).item())