@traceable()classExtendDataset(Dataset):"""ExtendDataset either extends or contracts the length of provided Dataset. Args: dataset: The Original dataset(s) which need expansion or contraction. spoof_length: Length to which original dataset must be expanded or contracted to. (New desired length) """def__init__(self,dataset:Dataset,spoof_length:int)->None:self.dataset=datasetself.spoof_length=spoof_lengthself._check_input()ifhasattr(dataset,"fe_reset_ds"):self.fe_reset_ds=dataset.fe_reset_dsifhasattr(dataset,"fe_batch_indices"):self.fe_batch_indices=dataset.fe_batch_indicesifhasattr(dataset,"fe_batch"):self.fe_batch=dataset.fe_batchdef__len__(self):returnlen(self.dataset)def_check_input(self)->None:"""Verify that the given input values are valid. Raises: AssertionError: If any of the parameters are found to by unacceptable for a variety of reasons. """assertisinstance(self.spoof_length,int),"Only accept positive integer type as spoof_length"assertself.spoof_length>0,"Invalid spoof_length. Expand Length cannot be less than or equal to 0"assertnotisinstance(self.dataset,ExtendDataset),"Input Dataset cannot be an ExtendDataset object"def__getitem__(self,index):returnself.dataset[index]