So the problem looks to be in the way you defined your model. In pytorch when using a model and the nn library you need to define the model before you can execute the forward pass in it. Currently you do  not define your model before you are trying to use it so it is still expecting the number of classes and not an input to the model. You probably want to define your model before hand. You can do something like this:
model = ResNet18(num_classes)
train(train_dataset,model,criterion1,criterion2,optimizer,epoch=2,result_directory=result_dir )

then just input how many classes the model should output where I wrote num_classes. This will initialize your model correctly.