Premium problem47. Unsqueeze at a Given Dimension

Easy Locked

Insert a new size-1 dimension into tensor x at position dim.

Input

x =
tensor([[0, 1, 2],
        [3, 4, 5]])
dim = 1

Output

tensor([[[0, 1, 2]],

        [[3, 4, 5]]])

Premium problem

This one's part of Premium. Unlock the full PyTorch track plus every other premium problem on the site.

Implement solve(...)