class_docstr: FlashBaseFinetuning can be used to create a custom Flash Finetuning Callback.
class_docstr_tok: ["FlashBaseFinetuning","can","be","used","to","create","a","custom","Flash","Finetuning","Callback","."]
code: def _unfreeze_milestones_function(
      self,
      pl_module: Union[Module, Iterable[Union[Module, Iterable]]],
      epoch: int,
      optimizer: Optimizer,
      opt_idx: int,
      strategy_metadata: Tuple[Tuple[int, int], int],
  ):
      unfreeze_milestones: Tuple[int, int] = strategy_metadata[0]
      num_layers: int = strategy_metadata[1]
  
      modules = self._get_modules_to_freeze(pl_module=pl_module)
      if modules is not None:
          if epoch == unfreeze_milestones[0]:
              # unfreeze num_layers last layers
  
              backbone_modules = BaseFinetuning.flatten_modules(
                  modules=modules
              )[-num_layers:]
              self.unfreeze_and_extend_param_group(
                  modules=backbone_modules,
                  optimizer=optimizer,
                  train_bn=self.train_bn,
              )
          elif epoch == unfreeze_milestones[1]:
              # unfreeze remaining layers
              backbone_modules = BaseFinetuning.flatten_modules(
                  modules=modules
              )[:-num_layers]
              self.unfreeze_and_extend_param_group(
                  modules=backbone_modules,
                  optimizer=optimizer,
                  train_bn=self.train_bn,
              )
  
imports: import os
  from functools import partial
  from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
  from pytorch_lightning import LightningModule
  from pytorch_lightning.callbacks import BaseFinetuning
  from torch.nn import Module
  from torch.optim import Optimizer
  from flash.core.registry import FlashRegistry
label_desc: Use image node_id 6 for calling the FlashBaseFinetuning obj's underlying member method code with example usage: obj._unfreeze_milestones_function(pl_module, epoch, optimizer, opt_idx, strategy_metadata) without return types