    def set_slice(self, slice_num: int, freeze: bool = True):
        """
        Freeze/unfreeze layers by list slice.

        Args:
            slice_num (`int`):
                number to slice the list of layers
            freeze (`bool`):
                if or not freeze layers (default: True)
        """
        myslice = slice(slice_num)
        slice_idx = list(range(self.layer_count))[myslice]
        self.by_idx(idx=slice_idx, freeze=freeze)
Freeze/unfreeze layers by list slice.

Args:
slice_num (`int`):
number to slice the list of layers
freeze (`bool`):
if or not freeze layers (default: True)
towhee/trainer/utils/layer_freezer.py