Try
k, h, w = 2, 8, 8
index = [[4, 4, 8, 8], [2, 2, 6, 6]]
hh, ww = torch.meshgrid(torch.arange(h), torch.arange(w))
hh, ww = hh.repeat(k, 1, 1), ww.repeat(k, 1, 1)
index = torch.tensor(index).long()
hh = torch.logical_and(index[:, 0, None, None] <= hh, hh < index[:, 2, None, None])
ww = torch.logical_and(index[:, 1, None, None] <= ww, ww < index[:, 3, None, None])
mask = torch.logical_and(hh, ww)
print(mask)

PS: i am not sure it is faster than for loop, test it by your self.