You could use broadcasting to get the desired result:
x = torch.tensor([[[1., 3.],
                   [2., 4.]],
                  [[5., 7.],
                   [9., 8.]]])

quantile = torch.tensor([torch.quantile(a, 1/2) for a in x])

res = torch.where(x > quantile[:, None, None], 1, 0)
print(res)
> tensor([[[0, 1],
           [0, 1]],

          [[0, 0],
           [1, 1]]])