Thanks.  It looks like this code masks a single rectangle in a single image, which is easy to do.
More specifically:
Looping through the whole sequence to choose points to start blocks at is probably fine if it is done in C++, but it is probably slow in python, so I thought there might be some vectorized alternative.  Another approach would be to draw the number of blocks from the binomial distribution and then choose that number of indices (not sure what function does this) and then loop through these indices, which is probably faster but still not nice to have to do in python.  In either case, the actual masking can be done using array index notation so long as we arrange for the batch and time dimensions to come first (which can be done by transposing, which is pretty fast I guess).
The torch.Transforms code only works on one image at a time; it is meant for data loaders.  That might be OK for my case, but ideally masking would work as a layer.