docstr: TransferLearningModel
  Args:
      backbone: Name (as in ``torchvision.models``) of the feature extractor
      train_bn: Whether the BatchNorm layers should be trainable
      milestones: List of two epochs milestones
      lr: Initial learning rate
      lr_scheduler_gamma: Factor by which the learning rate is reduced at each milestone
docstr_tok: ["TransferLearningModel","Args",":","backbone",":","Name","(","as","in","``","torchvision.models","``",")","of","the","feature","extractor","train_bn",":","Whether","the","BatchNorm","layers","should","be","trainable","milestones",":","List","of","two","epochs","milestones","lr",":","Initial","learning","rate","lr_scheduler_gamma",":","Factor","by","which","the","learning","rate","is","reduced","at","each","milestone"]
code: def __init__(
      self,
      backbone: str = "resnet50",
      train_bn: bool = False,
      milestones: tuple = (2, 4),
      batch_size: int = 32,
      lr: float = 1e-3,
      lr_scheduler_gamma: float = 1e-1,
      num_workers: int = 6,
      **kwargs,
  ) -> None:
      """TransferLearningModel
      Args:
          backbone: Name (as in ``torchvision.models``) of the feature extractor
          train_bn: Whether the BatchNorm layers should be trainable
          milestones: List of two epochs milestones
          lr: Initial learning rate
          lr_scheduler_gamma: Factor by which the learning rate is reduced at each milestone
      """
      super().__init__()
      self.backbone = backbone
      self.train_bn = train_bn
      self.milestones = milestones
      self.batch_size = batch_size
      self.lr = lr
      self.lr_scheduler_gamma = lr_scheduler_gamma
      self.num_workers = num_workers
  
      self.__build_model()
  
      self.train_acc = MulticlassAccuracy(num_classes=2)
      self.valid_acc = MulticlassAccuracy(num_classes=2)
      self.save_hyperparameters()
  
imports: import logging
  from pathlib import Path
  from typing import Union
  import torch
  import torch.nn.functional
  from torch import nn, optim
  from torch.optim.lr_scheduler import MultiStepLR
  from torch.optim.optimizer import Optimizer
  from torch.utils.data import DataLoader
  from torchmetrics.classification import MulticlassAccuracy
  from torchvision import models
  from bigdl.nano.pytorch.vision.datasets import ImageFolder
  from bigdl.nano.pytorch.vision.transforms import transforms
  from torchvision.datasets.utils import download_and_extract_archive
  import pytorch_lightning
  from pl_examples import cli_lightning_logo
  from pytorch_lightning import LightningDataModule
  from pytorch_lightning.callbacks.finetuning import BaseFinetuning
  from pytorch_lightning.utilities import rank_zero_info
  from pytorch_lightning.utilities.cli import LightningCLI
label_desc: Use image node_id 1 to create a new TransferLearningModel object from inherited base classes: pl with example: obj = TransferLearningModel(backbone, train_bn, milestones, batch_size, lr, lr_scheduler_gamma, num_workers)