if size is None:
size_prod = 1
if ~isinstance(size, int):
size_prod = torch.prod(torch.Tensor(size))
if p is None:
p = torch.ones_like(a) / len(a)
After Change
size_prod = 1
elif not isinstance(size, int):
size_prod = int(torch.prod(torch.Tensor(size)).item())
if p is None:
p = torch.ones_like(a) / float(len(a))
sample = a[torch.multinomial(p, size_prod, replacement=replace)]