[1 , 2 ,[3, 4], 5] can not be converted correctly.

Well, it’s not a symmetric shape. it’s impossible to have a matrix that has a different number of elements in each row – it doesn’t exist. You can cast this into a vector though if that’s desired:
your_list = [1 , 2 ,[3, 4], 5] 

torch.tensor(list(
    itertools.chain(*[[i] if isinstance(i, int) else i for i in your_list])))

tensor([1, 2, 3, 4, 5])