thanks , the model is training now after I changed the following thing in training loop–>
for batch in dataloaders[phase]:
     if torch.cuda.is_available():
        inputs = batch['image'].cuda()
        labels = batch['class'].cuda()

but it is returning me same loss and accuracy at every iternation of the epoch , please help me as I am really finding it difficult to solve it by my own.
setting up the optimizer , loss func. & scheduler for training
from cutmix.utils import CutMixCrossEntropyLoss 
from torchcontrib.optim import SWA #for Stochastic Weight Averaging in PyTorch


base_optimizer = torch.optim.Adam(model.parameters(), lr=0.001)

optimizer = SWA(base_optimizer, swa_start=5, swa_freq=5, swa_lr=0.05)

loss_fn = CutMixCrossEntropyLoss(True)

scheduler = torch.optim.lr_scheduler.StepLR(optimizer, step_size=7, gamma=0.1)

setting a function to freeze the parameters learned in a pretrained model
def set_parameters_requires_grad(model , extracting):
    if extracting:
        for param in model.parameters():
            param.requires_grad = False

setting up the training function
if __name__ == "__main__":
    
    set_parameters_requires_grad(model , True)
    
    epochs = 25
    
    for epoch in range(epochs):
        print('Epoch ', epoch,'/',epochs-1)
        print('-'*15)

        for phase in ['train', 'val']:
            if phase == 'train':
                model.train()  # Set model to training mode
            else:
                model.eval()   # Set model to evaluate mode

        running_loss = 0.0
        running_corrects = 0.0

        # Iterate over data.
        for batch in dataloaders[phase]:
            if torch.cuda.is_available():
                inputs = batch['image'].cuda()
                labels = batch['class'].cuda()
    
            # zero the parameter gradients
            optimizer.zero_grad()

            with torch.set_grad_enabled(phase == 'train'):
                outputs = model(inputs)
                _, preds = torch.max(outputs, 1)
                loss = loss_fn(outputs, labels)

                # we backpropagate to set our learning parameters only in training mode
                if phase == 'train':
                    loss.backward()
                    optimizer.step()

            running_loss += loss.item() * inputs.size(0)
            running_corrects += torch.sum(preds == labels.data)

        # scheduler for weight decay
        if phase == 'train':
            scheduler.step()

        epoch_loss = running_loss / dataset_sizes[phase]
        epoch_acc = running_corrects / dataset_sizes[phase]

        print('{} Loss: {:.4f} Acc: {:.4f}'.format(phase, epoch_loss, epoch_acc))
    optimizer.swap_swa_sgd()