class_docstr: Utilities to freeze/unfreeze layers.
  
  Args:
      model:
          a model with weights.
  Return:
      LayerFreezer.
  
  Example:
      >>> from towhee.trainer.utils.layer_freezer import LayerFreezer
      >>> from towhee.models import vit
      >>> my_model = vit.create_model()
      >>> my_freezer = LayerFreezer(my_model)
      >>> # Check if modules in the last layer are frozen
      >>> my_freezer.status(-1)
      >>> # Check if modules in the layer "head" are frozen
      >>> my_freezer.status("head")
      ['unfrozen', 'unfrozen']
      >>> # Show all frozen layers
      >>> my_freezer.show_frozen_layers()
      ['patch_embed', 'head']
      >>> # Freeze layers by a list of layer indexes
      >>> my_freezer.by_idx([0, -1])
      >>> # Freeze layers by a list of layer names
      >>> my_freezer.by_names(['head'])
      >>> # Freeze all layers
      >>> my_freezer.set_all()
      >>> # Unfreeze all layers
      >>> my_freezer.set_all(freeze=False)
      >>> # Freeze all except the last layer
      >>> my_freezer.set_slice(-1)
code: def __init__(self, model):
      self.model = model
      self.layer_names = list(dict(self.model.named_children()).keys())
      self.layer_count = len(self.layer_names)
  
file_path: towhee/towhee/trainer/utils/layer_freezer.py
imports: from typing import Union
label_desc: Use image node_id 1 to create a new LayerFreezer object  with example: obj = LayerFreezer(model)