You could create the values using the defined number of samples beforehand, shuffle them, and reshape to the desired output:
ones, zeros = 30, 70
x = torch.cat((torch.zeros(zeros), torch.ones(ones)))
x = x[torch.randperm(x.size(0))]
x = x.view(10, 10)
print(x)
> tensor([[0., 0., 0., 0., 0., 0., 0., 1., 0., 0.],
[1., 0., 0., 0., 0., 0., 1., 1., 1., 1.],
[1., 0., 0., 0., 0., 0., 1., 0., 0., 0.],
[0., 0., 1., 1., 0., 0., 1., 0., 1., 0.],
[0., 1., 0., 0., 0., 1., 1., 0., 0., 0.],
[0., 0., 0., 1., 1., 0., 0., 0., 1., 1.],
[1., 0., 0., 0., 0., 0., 1., 1., 0., 0.],
[0., 0., 0., 0., 1., 1., 0., 0., 0., 0.],
[0., 1., 1., 0., 0., 0., 1., 0., 0., 0.],
[1., 0., 0., 0., 0., 0., 1., 0., 1., 0.]])