code: def fine_tune_model(num_epochs, data_dir, learning_rate, momentum):
      """Load a pretrained model and reset the final fully connected layer."""
  
      # log the hyperparameter metrics to the AML run
      run.log("lr", np.float(learning_rate))
      run.log("momentum", np.float(momentum))
  
      model_ft = models.resnet18(pretrained=True)
      num_ftrs = model_ft.fc.in_features
      model_ft.fc = nn.Linear(num_ftrs, 2)  # only 2 classes to predict
  
      device = torch.device(
          "cuda:0" if torch.cuda.is_available() else "cpu"
      )
      model_ft = model_ft.to(device)
  
      criterion = nn.CrossEntropyLoss()
  
      # Observe that all parameters are being optimized
      optimizer_ft = optim.SGD(
          model_ft.parameters(), lr=learning_rate, momentum=momentum
      )
  
      # Decay LR by a factor of 0.1 every 7 epochs
      exp_lr_scheduler = lr_scheduler.StepLR(
          optimizer_ft, step_size=7, gamma=0.1
      )
  
      model = train_model(
          model_ft,
          criterion,
          optimizer_ft,
          exp_lr_scheduler,
          num_epochs,
          data_dir,
      )
  
      return model
  
file_path: MachineLearningNotebooks/how-to-use-azureml/ml-frameworks/pytorch/train-hyperparameter-tune-deploy-with-pytorch/pytorch_train.py
imports: from __future__ import print_function, division
  import torch
  import torch.nn
  import torch.optim
  from torch.optim import lr_scheduler
  from torchvision import datasets, models, transforms
  import numpy
  import time
  import os
  import copy
  import argparse
  from azureml.core.run import Run
label_desc: Use image node_id 3 for calling a global function with example usage: fine_tune_model(num_epochs, data_dir, learning_rate, momentum) and returns: model