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","."]
docstr: Args:
      strategy_key: The finetuning strategy to be used. See :meth:`~flash.core.trainer.Trainer.finetune`
          for the available strategies.
      strategy_metadata: Data that accompanies certain finetuning strategies like epoch number or number of
          layers.
      train_bn: Whether to train Batch Norm layer
docstr_tok: ["Args",":","strategy_key",":","The","finetuning","strategy","to","be","used",".","See",":","meth",":","`","~flash.core.trainer.Trainer.finetune","`","for","the","available","strategies",".","strategy_metadata",":","Data","that","accompanies","certain","finetuning","strategies","like","epoch","number","or","number","of","layers",".","train_bn",":","Whether","to","train","Batch","Norm","layer"]
code: def __init__(
      self,
      strategy_key: Union[str, FinetuningStrategies],
      strategy_metadata: Optional[
          Union[int, Tuple[Tuple[int, int], int]]
      ] = None,
      train_bn: bool = True,
  ):
      """
      Args:
          strategy_key: The finetuning strategy to be used. See :meth:`~flash.core.trainer.Trainer.finetune`
              for the available strategies.
          strategy_metadata: Data that accompanies certain finetuning strategies like epoch number or number of
              layers.
          train_bn: Whether to train Batch Norm layer
      """
      super().__init__()
  
      self.strategy: FinetuningStrategies = strategy_key
      self.strategy_metadata: Optional[
          Union[int, Tuple[Tuple[int, int], int]]
      ] = strategy_metadata
      self.train_bn: bool = train_bn
  
      if (
          self.strategy == FinetuningStrategies.FREEZE_UNFREEZE
          and not isinstance(self.strategy_metadata, int)
      ):
          raise TypeError(
              "The `freeze_unfreeze` strategy requires an integer denoting the epoch number to unfreeze at. Example: "
              "`strategy=('freeze_unfreeze', 7)`"
          )
      if (
          self.strategy == FinetuningStrategies.UNFREEZE_MILESTONES
          and not (
              isinstance(self.strategy_metadata, Tuple)
              and isinstance(self.strategy_metadata[0], Tuple)
              and isinstance(self.strategy_metadata[1], int)
              and isinstance(self.strategy_metadata[0][0], int)
              and isinstance(self.strategy_metadata[0][1], int)
          )
      ):
          raise TypeError(
              "The `unfreeze_milestones` strategy requires the format Tuple[Tuple[int, int], int]. Example: "
              "`strategy=('unfreeze_milestones', ((5, 10), 15))`"
          )
  
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 1 to create a new FlashBaseFinetuning object from inherited base classes: BaseFinetuning with example: obj = FlashBaseFinetuning(strategy_key, strategy_metadata, train_bn)