Here is a numpy solution for you.
inp = [
[0, 1,],
[0, 1, 2, 3],
[0, 1, 2]
]
Now you can simply
import numpy as np
shp = []
for sub_list in inp:
shp.append(len(sub_list))
arr = np.ones(shp)
result = np.where(arr)
tuples = [t for t in zip(*result)]
out:
[(0, 0, 0),
(0, 0, 1),
(0, 0, 2),
(0, 1, 0),
(0, 1, 1),
(0, 1, 2),
(0, 2, 0),
(0, 2, 1),
(0, 2, 2),
(0, 3, 0),
(0, 3, 1),
(0, 3, 2),
(1, 0, 0),
(1, 0, 1),
(1, 0, 2),
(1, 1, 0),
(1, 1, 1),
(1, 1, 2),
(1, 2, 0),
(1, 2, 1),
(1, 2, 2),
(1, 3, 0),
(1, 3, 1),
(1, 3, 2)]
The way this works, is you build an array of ones whose dimensions are the lengths of your lists.
Then you get the multi dimensional indices of this array, which happen to be exactly what you wanted.
If you also want to access your lists in the relevant index, you can easily do that as well.
for tup in itertools.product(*your_array):The ordering won't be as shown above, but to be honest what you've shown there seems a somewhat random order anyway.