As the error reports it didn’t load the .nii file but still the C:\Users\....\train\1 directory.
In your exemple you should changes these lines:
datapath = [patient_id, 'C:/Users/Ali ktk/.spyder-py3/dataloader/data/train/1'] #[patient_id, path]

into
datapath = patient_id

And to load the images properly with nibabel change
mri = nib.load(cwd).get_data()

into
mri = nib.load(path).get_data()

BTW all these questions are not related to pytorch at all maybe it’s more suited to go on the nibabel forum/gitter/whatever they use to communicate, to learn how to properly load medical imaging data