    def status(self, layer: Union[str, int]):
        """
        Check if a layer is frozen or not by its name or index

        Args:
            layer (`Union[str, int]`):
                the name or index of layer.
        Return:
            A list of status ('frozen' or 'unfrozen') to indicate if modules in the layer are frozen or not.
        """
        if isinstance(layer, str):
            if layer not in self.layer_names:
                raise ValueError(f'Layer does not exist: {layer}')
            for name, child in self.model.named_children():
                if name == layer:
                    outs = []
                    for param in child.parameters():
                        outs.append('unfrozen' if param.requires_grad else 'frozen')
                    print(f'Freeze status of layer {layer}: {outs}')
                    return outs
        if isinstance(layer, int):
            outs = []
            for param in list(self.model.children())[layer].parameters():
                outs.append('unfrozen' if param.requires_grad else 'frozen')
            print(f'Freeze status of layer {layer}: {outs}')
            return outs
Check if a layer is frozen or not by its name or index

Args:
layer (`Union[str, int]`):
the name or index of layer.
Return:
A list of status ('frozen' or 'unfrozen') to indicate if modules in the layer are frozen or not.
towhee/trainer/utils/layer_freezer.py