I think the problem is for this part. I want to load the image which the name is in the defined list (not all). and with this command nothing for some times nothing is  passed.
class CustomDataSetZoneAbnormal_HMScan():
    def __init__(self, main_dir, dirusedList,transforms,zone):
        self.main_dir = main_dir
        self.zone=zone
        self.transforms = transforms
        self.dirusedList=np.load(dirusedList)

        all_imgs = os.listdir(main_dir)
        self.total_imgs = sorted(all_imgs)
       


    def __getitem__(self, idx):
                    
        cc=self.total_imgs[idx]
        ccSplit= cc.split('.')
        ccSplitsec=ccSplit[-2].split('_')
        ccSplitTh=ccSplitsec[:-2]
        for ii in range(len(self.dirusedList)):

            if ccSplitTh==self.dirusedList[ii]:

                img_loc = os.path.join(self.main_dir, self.total_imgs[idx])

                image11=mpimg.imread(img_loc).astype(float)

                return image11
           
            else:
                continue    
    
    def __len__(self):
        return len(self.total_imgs)