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 = Accuracy(task="binary")
      self.valid_acc = Accuracy(task="binary")
      self.save_hyperparameters()
  
imports: import logging
  from pathlib import Path
  from typing import Union
  import torch
  import torch.nn.functional
  from lightning.pytorch import LightningDataModule, LightningModule, cli_lightning_logo
  from lightning.pytorch.callbacks.finetuning import BaseFinetuning
  from lightning.pytorch.cli import LightningCLI
  from lightning.pytorch.utilities import rank_zero_info
  from lightning.pytorch.utilities.model_helpers import get_torchvision_model
  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 import Accuracy
  from torchvision import transforms
  from torchvision.datasets import ImageFolder
  from torchvision.datasets.utils import download_and_extract_archive
label_desc: Use image node_id 1 to create a new TransferLearningModel object from inherited base classes: LightningModule with example: obj = TransferLearningModel(backbone, train_bn, milestones, batch_size, lr, lr_scheduler_gamma, num_workers)