def expand_dims(var, dim=0):
    ' Is similar to [numpy.expand_dims](https://docs.scipy.org/doc/numpy/reference/generated/numpy.expand_dims.html).\n        var = torch.range(0, 9).view(-1, 2)\n        torch.expand_dims(var, 0).size()\n        # (1, 5, 2)\n    '
    sizes = list(var.size())
    sizes.insert(dim, 1)
    return var.view(*sizes)
Is similar to [numpy.expand_dims](https://docs.scipy.org/doc/numpy/reference/generated/numpy.expand_dims.html).
var = torch.range(0, 9).view(-1, 2)
torch.expand_dims(var, 0).size()
# (1, 5, 2)
def expand_dims(var, dim=0):
    ' Is similar to [numpy.expand_dims](https://docs.scipy.org/doc/numpy/reference/generated/numpy.expand_dims.html).\n        var = torch.range(0, 9).view(-1, 2)\n        torch.expand_dims(var, 0).size()\n        # (1, 5, 2)\n    '
    sizes = list(var.size())
    sizes.insert(dim, 1)
    return var.view(*sizes)