def unsquash_dim(tensor, dim, res_dim):
    """
    Unsquashes dimension, given in dim into separate dimensions given is res_dim
    Args:
        tensor (Tensor): input tensor
        dim (int): dimension that should be unsquashed
        res_dim (tuple): list of dimensions, that given dim should be unfolded to

    """
    size = tensor.size()
    result_dim = size[:dim] + res_dim + size[dim + 1:]
    return tensor.view(*result_dim)