I think we are misunderstanding each other here 
I just wanted to point to the indentation of your code (i.e. how many spaces/tabs are in front of the code):
# Your current version
def run():
    ##Training the model
    def train_model(model, criterion, optimizer, scheduler, num_epochs=2):
        since = time.time()  # only this line of code will be executed in train_model!

    best_model_wts = copy.deepcopy(model.state_dict())
    best_acc = 0.0

    for epoch in range(num_epochs):
        print('Epoch {}/{}'.format(epoch, num_epochs - 1))
        print('-' * 10)

While maybe you wanted to write your code like this:
def run():
    ##Training the model
    def train_model(model, criterion, optimizer, scheduler, num_epochs=2):
        # Now all lines will be executed in train_model!
        since = time.time()

        best_model_wts = copy.deepcopy(model.state_dict())
        best_acc = 0.0

        for epoch in range(num_epochs):
            print('Epoch {}/{}'.format(epoch, num_epochs - 1))
            print('-' * 10)

Could you check for this types of error?