CDhere:


ones_like
.ones_like() takes tensor as an input argument
input = torch.empty(2, 3)
torch.ones_like(input)

new_ones
new_ones is a member function of the tensor object

>>> tensor = torch.tensor((), dtype=torch.int32)
>>> tensor.new_ones((2, 3))
tensor([[ 1,  1,  1],
        [ 1,  1,  1]], dtype=torch.int32)