def freeze(self, freeze_at=0):
        """
        Freeze the first several stages of the ResNet. Commonly used in
        fine-tuning.
        Args:
            freeze_at (int): number of stem and stages to freeze.
                `1` means freezing the stem. `2` means freezing the stem and
                the first stage, etc.
        Returns:
            nn.Module: this ResNet itself
        """
        if freeze_at >= 1:
            self.stem.freeze()
        for idx, (stage, _) in enumerate(self.stages_and_names, start=2):
            if freeze_at >= idx:
                for block in stage.children():
                    block.freeze()
        return self

        Freeze the first several stages of the ResNet. Commonly used in
        fine-tuning.
        Args:
            freeze_at (int): number of stem and stages to freeze.
                `1` means freezing the stem. `2` means freezing the stem and
                the first stage, etc.
        Returns:
            nn.Module: this ResNet itself
        
iGPT/models/grit_src/third_party/CenterNet2/projects/CenterNet2/centernet/modeling/backbone/res2net.py