Here first you need to store the Input and attribute location using
a dictionary in python with Input file name as key and Attribute file name as Value.
Then you can split the key of the dictionary and use that as input.
from glob import glob
MainFolder="<Your Folder Name>"
Data={}
for file in glob(MainFolder+"/*.dat"):
At_file=file[:-3]+"atr"
Data[file]=At_file
# Here Data would have Input and attribute file name as key and value pair
# To split the date:
Key_data=list(Data)
import random
random.shuffle(Key_data)
#Here you specify the split ratio of Training and Testing
split=int(len(Key_data)*(0.8))
Train_in=Key_data[:split]
Test_in=Key_data[split:]
Train_at=[Data[i] for i in Train_in]
Test_at=[Data[i] for i in Test_in]
print(Train_in,Train_at,Test_in,Test_at)
Here Train_in is the Input files and Train_at is its corresponding attribute files
This should solve your problem. Comment if you get any error in implementing the above code.