Split_by_valid func on custom Itemlist

Information about my target-
I’m following the site’s tutorial.
Except I want ItemsB to be deteminstiacally set and not randomly.

The problem-
Whenever I call split_by_valid func it divides the Itemlist according to the items attribute and leaving itemsB undivided. This creates a mismatch between the indexes of items and itemsB.

Was wondering If anyone has an idea how to overcome this.

Code -

class ImageTupleList(ImageList):
    def __init__(self, items, itemsB=None, **kwargs):
        super().__init__(items, **kwargs)
        self.itemsB = itemsB
    def get(self, i):
        img1 = super().get(i)
        fn = self.itemsB[i]
        return ImageTuple(img1, open_image(fn))
    def reconstruct(self, t:Tensor): 
        return ImageTuple(Image(t[0]/2+0.5),Image(t[1]/2+0.5))
    def from_folders(cls, path, folderA, folderB, **kwargs):
        itemsB = ImageList.from_folder(path/folderB).items
        res = super().from_folder(path/folderA, itemsB=itemsB, **kwargs)
        res.path = path
        return res

My starting point was to somehow override the split function but the whole datablock API is very dependent on the Itemlists having the attribute item which is a list so I got stuck.

Solution - TL;DR create ItemLists.
The split functions eventually create an ItemLists object. so If the split function can’t help us lets create this object ourselves .
Create two ImageTupleList object, one for training one for validation then use them to create ItemLists. The created object can undergo the standard label creation and become a Databunch using.databunch().