No attribute 'on_init_start'

I wanted to make a custom data module, I got an error that ‘TranslationDataModule’ object has no attribute ‘on_init_start’
This is my DataModule definition.
Can anybody please help? I used DataModules before and didn’t face this error…

import pytorch_lightning as pl
from torchvision import transforms
class TranslationDataModule(pl.LightningDataModule):

def __init__(self, train_path):


    self.train_path = train_path
    self.transform = transforms.Compose([TokenizeAndNumericalise(n_en, n_te), ])

def prepare_data(self):
    # download the dataset
    ParallelDataset(self.train_path, transform=self.transform)

def setup(self, stage=None):

    # Assign train/val datasets for use in dataloaders
    if stage == "fit" or stage is None:
        self.train_dataset = ParallelDataset(self.train_path, transform=self.transform)

def train_dataloader(self):
    return, batch_size=4,
                    shuffle=True, num_workers=0, collate_fn=collate_fn_padd)

Did you mean to return this? Or set this as a parameter? I think if you don’t need this function you should just delete it.

No I didn’t want return it, It downloads the dataset from the path. That is why I have it in place, the actual setting of values is being done in setup() method.

it’s weird, on_init_start is specific to callbacks. Can you put the piece of code where you initialize your trainer, datamodule and call here? Also pl version too?

dm = TranslationDataModule('train_dataset.csv')
trainer = pl.Trainer(fast_dev_run=True, gpus=1, profiler=True), dm)

I have already checked it in parts and it was working as intended. I’m not sure what is the exact problem here. This is code is what I use most of the time, and never faced this particular error. The pytorch_lightning version I’m using is v0.9.0.

Maybe I had messed up somewhere else in the code because I tried reproducing the same error in a different notebook but couldn’t. So, I restarted my kernel and it is working normally.