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 _get_modules_to_freeze(
      self, pl_module: LightningModule
  ) -> Union[Module, Iterable[Union[Module, Iterable]]]:
      modules_to_freeze = getattr(pl_module, "modules_to_freeze", None)
      if modules_to_freeze is None:
          raise AttributeError(
              "LightningModule missing instance method 'modules_to_freeze'."
              "Please, implement the method which returns NoneType or a Module or an Iterable of Modules."
          )
      return modules_to_freeze()
  
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 2 for calling the FlashBaseFinetuning obj's underlying member method code with example usage: obj._get_modules_to_freeze(pl_module) and returns: modules_to_freeze