The the indices evenly spaced?
If so, you could try:
a = torch.zeros(5, 5)
a[::2, ::2] = 1
print(a)
> tensor([[ 1.,  0.,  1.,  0.,  1.],
          [ 0.,  0.,  0.,  0.,  0.],
          [ 1.,  0.,  1.,  0.,  1.],
          [ 0.,  0.,  0.,  0.,  0.],
          [ 1.,  0.,  1.,  0.,  1.]])