The error doesn’t seem to be raised by the usage of random_split and should also be raised, if you try to index image_datasets directly, as the passed transformation seems to be defined in a wrong way.
While you are using:
data_transforms = {
transforms.Compose([
transforms.Resize((224,224)),
transforms.ToTensor()
]),
}

which will create a set object.
Remove the curly brackets and rerun the code.
PS: you can post code snippets by wrapping them into three backticks, which makes debugging easier.