Is torch.empty_like() dependent on the input value as well as input size?
The description in the torch docs for torch.empty_like says:

torch.empty_like(input, *, dtype=None, layout=None, device=None, requires_grad=False, memory_format=torch.preserve_format) → Tensor
Returns an uninitialized tensor with the same size as input. torch.empty_like(input) is equivalent to torch.empty(input.size(), dtype=input.dtype, layout=input.layout, device=input.device).
Parameters
input (Tensor) – the size of input will determine size of the output tensor.

What I do is :
&gt;&gt;&gt; torch.empty(3,4)
tensor([[-1.8597e+15,  4.5657e-41, -1.8597e+15,  4.5657e-41],
        [ 4.4842e-44,  0.0000e+00,  8.9683e-44,  0.0000e+00],
        [ 0.0000e+00,  0.0000e+00,  0.0000e+00,  0.0000e+00]])

&gt;&gt;&gt; c1
tensor([[ 0,  1,  2,  3],
        [ 4,  5,  6,  7],
        [ 8,  9, 10, 11]])

&gt;&gt;&gt; torch.empty_like(c1)
tensor([[139942262173040,  93851872482144,               1,               0],
        [              0,               0,  93851872492496,               0],
        [              0,               0,               0,               0]])

&gt;&gt;&gt; d
tensor([[0., 0., 0., 0.],
        [0., 0., 0., 0.],
        [0., 0., 0., 0.]])

&gt;&gt;&gt; torch.empty_like(d)
tensor([[-8.6092e-25,  3.0620e-41,  0.0000e+00,  0.0000e+00],
        [ 0.0000e+00,  0.0000e+00,  0.0000e+00,  0.0000e+00],
        [ 0.0000e+00,  0.0000e+00,  0.0000e+00,  0.0000e+00]])

It seems that the tensor returned by torch.empty_like depends on input value, contrary to the description in the docs. Can someone explain this?

The docs description is correct. I am not sure if you are confused by torch.empty_like returning different outputs on different calls, but you can see this is also the behaviour of torch.empty by calling e.g. torch.empty((2,3), dtype=torch.int64) multiple times.
Note torch.empty_like does depend on the dtype of the input (but not its specific values).
