Argument "source" is not supported by operator "ExternalSource"

Hi, i’m trying to load data Using external source in DALI
I followed the getting started guide, the documentation says

The  `ExternalSource`  operator accepts an iterable or a callable. If the source provides multiple outputs (e.g. images and labels), that number must also be specified as  `num_outputs`  argument.

Now i create a iterable class for the kitti directory structure

class KittiLoader(object):
    def __init__(self, batch_size, image_dir, annotation_dir, shuffle=False):
        self.image_dir = image_dir
        self.annotation_dir = annotation_dir
        self.batch_size = batch_size
        
        self.images = np.array(os.listdir(self.image_dir))
        if shuffle: np.random.shuffle(self.images)
        self.annotations = np.array([x.rsplit(".")[0]+".txt" for x in self.images])
        
        self.i = 0
        self.n = len(self.images)

    def __iter__(self):
        self.i = 0
        self.n = len(self.images)
        return self

    def __next__(self):
        images = []
        annotations = []
        for _ in range(self.batch_size):
            imageFile = os.path.join(self.image_dir, self.images[self.i])
            annotationFile = os.path.join(self.annotation_dir, self.annotations[self.i])
            
            if os.path.exists(annotationFile):
                with open(imageFile, 'rb') as f:
                    images.append(np.frombuffer(f.read(), dtype = np.uint8))
                
                with open(annotationFile, "r") as f:
                    ann = f.read().strip().split("\n")
                    ann = map(lambda x:[i for i in x.split(" ")], ann)
                    ann = list(map(lambda x:[x[0], x[4], x[5], x[6], x[7]], ann))
                    annotations.append(ann)
        
                self.i = (self.i + 1) % self.n
            
        return (images, annotations)

image_dir = "/workspace/tlt_trainer_test_dataset/images"
annotation_dir = "/workspace/tlt_trainer_test_dataset/annotations"
batch_size = 8
kl = KittiLoader(batch_size, image_dir, annotation_dir)

I tried to iterate over the class and able to get the next batch, but when i pass the iterator to DALI pipeline:

class KittiPipeline(Pipeline):
    def __init__(self, batch_size, num_threads, device_id):
        super(KittiPipeline, self).__init__(batch_size, num_threads, device_id, seed=42)

        self.source = ops.ExternalSource(source = kl, num_outputs = 2)
        self.decode = ops.ImageDecoder(device = "mixed", output_type = types.RGB)

    def define_graph(self):
        images, annotations = self.source()
        images = self.decode(images)
        return (images, annotations)
pipe = KittiPipeline(batch_size, num_threads=2, device_id = 0)
pipe.build()

It fails with an error:

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-133-f95ba9959b65> in <module>
----> 1 pipe = KittiPipeline(batch_size, num_threads=2, device_id = 0)
      2 pipe.build()
      3 pipe_out = pipe.run()

<ipython-input-132-6ee755096e9f> in __init__(self, batch_size, num_threads, device_id)
      3         super(KittiPipeline, self).__init__(batch_size, num_threads, device_id, seed=42)
      4 
----> 5         self.source = ops.ExternalSource(source = kl, num_outputs = 2)
      6         self.decode = ops.ImageDecoder(device = "mixed", output_type = types.RGB)
      7         #self.enhance = ops.BrightnessContrast(device = "gpu", contrast = 2)

/usr/local/lib/python3.6/dist-packages/nvidia/dali/ops.py in __init__(self, **kwargs)
    446                   continue
    447 
--> 448                 dtype = self._schema.GetArgumentType(key)
    449                 if isinstance(value, (list, tuple)):
    450                     if len(value) == 0:

RuntimeError: [/opt/dali/dali/pipeline/operator/op_schema.cc:127] Assert on "HasArgument(name)" failed: Argument "source" is not supported by operator "ExternalSource".
Stacktrace (100 entries):
[frame 0]: /usr/local/lib/python3.6/dist-packages/nvidia/dali/libdali.so(+0x6926e) [0x7f1fe9d1926e]
[frame 1]: /usr/local/lib/python3.6/dist-packages/nvidia/dali/libdali.so(dali::OpSchema::GetArgumentType(std::string const&) const+0x42b) [0x7f1fe9dd356b]
[frame 2]: /usr/local/lib/python3.6/dist-packages/nvidia/dali/backend_impl.cpython-36m-x86_64-linux-gnu.so(+0x42984) [0x7f1feb122984]
[frame 3]: /usr/local/lib/python3.6/dist-packages/nvidia/dali/backend_impl.cpython-36m-x86_64-linux-gnu.so(+0x20553) [0x7f1feb100553]
[frame 4]: /usr/bin/python(_PyCFunction_FastCallDict+0x35c) [0x5674fc]
[frame 5]: /usr/bin/python() [0x50abb3]
[frame 6]: /usr/bin/python(_PyEval_EvalFrameDefault+0x449) [0x50c5b9]
[frame 7]: /usr/bin/python() [0x508245]
[frame 8]: /usr/bin/python(_PyFunction_FastCallDict+0x2e2) [0x509642]
[frame 9]: /usr/bin/python() [0x595311]
[frame 10]: /usr/bin/python() [0x54a6ff]
[frame 11]: /usr/bin/python() [0x551b81]
[frame 12]: /usr/bin/python(_PyObject_FastCallKeywords+0x19c) [0x5aa6ec]
[frame 13]: /usr/bin/python() [0x50abb3]
[frame 14]: /usr/bin/python(_PyEval_EvalFrameDefault+0x1220) [0x50d390]
[frame 15]: /usr/bin/python() [0x508245]
[frame 16]: /usr/bin/python(_PyFunction_FastCallDict+0x2e2) [0x509642]
[frame 17]: /usr/bin/python() [0x595311]
[frame 18]: /usr/bin/python() [0x54a6ff]
[frame 19]: /usr/bin/python() [0x551b81]
[frame 20]: /usr/bin/python(_PyObject_FastCallKeywords+0x19c) [0x5aa6ec]
[frame 21]: /usr/bin/python() [0x50abb3]
[frame 22]: /usr/bin/python(_PyEval_EvalFrameDefault+0x1220) [0x50d390]
[frame 23]: /usr/bin/python() [0x508245]
[frame 24]: /usr/bin/python() [0x516915]
[frame 25]: /usr/bin/python() [0x50a8af]
[frame 26]: /usr/bin/python(_PyEval_EvalFrameDefault+0x449) [0x50c5b9]
[frame 27]: /usr/bin/python() [0x58ebaa]
[frame 28]: /usr/bin/python(_PyEval_EvalFrameDefault+0x19f4) [0x50db64]
[frame 29]: /usr/bin/python() [0x58ebaa]
[frame 30]: /usr/bin/python(_PyEval_EvalFrameDefault+0x19f4) [0x50db64]
[frame 31]: /usr/bin/python() [0x58ebaa]
[frame 32]: /usr/bin/python() [0x50a94c]
[frame 33]: /usr/bin/python(_PyEval_EvalFrameDefault+0x449) [0x50c5b9]
[frame 34]: /usr/bin/python() [0x509d48]
[frame 35]: /usr/bin/python() [0x50aa7d]
[frame 36]: /usr/bin/python(_PyEval_EvalFrameDefault+0x449) [0x50c5b9]
[frame 37]: /usr/bin/python() [0x509d48]
[frame 38]: /usr/bin/python() [0x50aa7d]
[frame 39]: /usr/bin/python(_PyEval_EvalFrameDefault+0x449) [0x50c5b9]
[frame 40]: /usr/bin/python() [0x508245]
[frame 41]: /usr/bin/python(_PyFunction_FastCallDict+0x2e2) [0x509642]
[frame 42]: /usr/bin/python() [0x595311]
[frame 43]: /usr/bin/python(PyObject_Call+0x3e) [0x5a067e]
[frame 44]: /usr/bin/python(_PyEval_EvalFrameDefault+0x17f6) [0x50d966]
[frame 45]: /usr/bin/python() [0x508245]
[frame 46]: /usr/bin/python() [0x50a080]
[frame 47]: /usr/bin/python() [0x50aa7d]
[frame 48]: /usr/bin/python(_PyEval_EvalFrameDefault+0x1220) [0x50d390]
[frame 49]: /usr/bin/python() [0x58efc9]
[frame 50]: /usr/bin/python() [0x5141df]
[frame 51]: /usr/bin/python() [0x50a8af]
[frame 52]: /usr/bin/python(_PyEval_EvalFrameDefault+0x449) [0x50c5b9]
[frame 53]: /usr/bin/python() [0x508245]
[frame 54]: /usr/bin/python() [0x50a080]
[frame 55]: /usr/bin/python() [0x50aa7d]
[frame 56]: /usr/bin/python(_PyEval_EvalFrameDefault+0x449) [0x50c5b9]
[frame 57]: /usr/bin/python() [0x58efc9]
[frame 58]: /usr/bin/python() [0x5141df]
[frame 59]: /usr/bin/python() [0x50a8af]
[frame 60]: /usr/bin/python(_PyEval_EvalFrameDefault+0x449) [0x50c5b9]
[frame 61]: /usr/bin/python() [0x508245]
[frame 62]: /usr/bin/python() [0x50a080]
[frame 63]: /usr/bin/python() [0x50aa7d]
[frame 64]: /usr/bin/python(_PyEval_EvalFrameDefault+0x449) [0x50c5b9]
[frame 65]: /usr/bin/python() [0x58efc9]
[frame 66]: /usr/bin/python() [0x5141df]
[frame 67]: /usr/bin/python() [0x50a8af]
[frame 68]: /usr/bin/python(_PyEval_EvalFrameDefault+0x449) [0x50c5b9]
[frame 69]: /usr/bin/python() [0x508245]
[frame 70]: /usr/bin/python(_PyFunction_FastCallDict+0x2e2) [0x509642]
[frame 71]: /usr/bin/python() [0x595311]
[frame 72]: /usr/bin/python(PyObject_Call+0x3e) [0x5a067e]
[frame 73]: /usr/bin/python(_PyEval_EvalFrameDefault+0x17f6) [0x50d966]
[frame 74]: /usr/bin/python() [0x58eb48]
[frame 75]: /usr/bin/python() [0x50a94c]
[frame 76]: /usr/bin/python(_PyEval_EvalFrameDefault+0x449) [0x50c5b9]
[frame 77]: /usr/bin/python() [0x509d48]
[frame 78]: /usr/bin/python() [0x50aa7d]
[frame 79]: /usr/bin/python(_PyEval_EvalFrameDefault+0x449) [0x50c5b9]
[frame 80]: /usr/bin/python() [0x508245]
[frame 81]: /usr/bin/python(_PyFunction_FastCallDict+0x2e2) [0x509642]
[frame 82]: /usr/bin/python(_PyObject_FastCallDict+0x4f1) [0x5a55a1]
[frame 83]: /usr/bin/python() [0x5f0b2c]
[frame 84]: /usr/bin/python(_PyObject_FastCallKeywords+0x19c) [0x5aa6ec]
[frame 85]: /usr/bin/python() [0x50abb3]
[frame 86]: /usr/bin/python(_PyEval_EvalFrameDefault+0x449) [0x50c5b9]
[frame 87]: /usr/bin/python() [0x509d48]
[frame 88]: /usr/bin/python() [0x50aa7d]
[frame 89]: /usr/bin/python(_PyEval_EvalFrameDefault+0x449) [0x50c5b9]
[frame 90]: /usr/bin/python() [0x508245]
[frame 91]: /usr/bin/python() [0x5893bb]
[frame 92]: /usr/bin/python(PyObject_Call+0x3e) [0x5a067e]
[frame 93]: /usr/bin/python(_PyEval_EvalFrameDefault+0x17f6) [0x50d966]
[frame 94]: /usr/bin/python() [0x509d48]
[frame 95]: /usr/bin/python() [0x50aa7d]
[frame 96]: /usr/bin/python(_PyEval_EvalFrameDefault+0x449) [0x50c5b9]
[frame 97]: /usr/bin/python() [0x509d48]
[frame 98]: /usr/bin/python() [0x50aa7d]
[frame 99]: /usr/bin/python(_PyEval_EvalFrameDefault+0x449) [0x50c5b9]

I also tried to wrap my iterator into a function like below

def wrapper():
    next(kl)

But it didn’t worked, please help with this.
Thanks