Get min value and index (of min value) from torch.tensor shape=(x,1)
I want to get a tensor of the min value and its index from a tensor. I have tried torch.min but am unsure how the return works to get BOTH value and index of minimum.
&gt;&gt;&gt; a = torch.tensor([[10], [5], [8], [2], [8]])

# Ideal output
&gt;&gt;&gt; min_value
[2]
&gt;&gt;&gt; min_index
[3]

How can I achieve this using torch.min?

Here is code example of torch.min usage which returns named tuple with both values and indices of min values. It may have multiple value/indices depending on input tensor shape and dim parameter.
&gt;&gt;&gt; result = torch.min(a, dim=0, keepdim=False)
&gt;&gt;&gt; result.values
tensor(2)
&gt;&gt;&gt; result.indices
tensor(3)

or simply a.min(dim=0)
