src/transformers/models/dinat/modeling_dinat.py/DinatBackbone/__init__
class DinatBackbone:    def __init__(self, config):
        super().__init__(config)

        requires_backends(self, ["natten"])

        self.stage_names = config.stage_names

        self.embeddings = DinatEmbeddings(config)
        self.encoder = DinatEncoder(config)

        self.out_features = config.out_features if config.out_features is not None else [self.stage_names[-1]]

        num_features = [int(config.embed_dim * 2**i) for i in range(len(config.depths))]
        self.out_feature_channels = {}
        self.out_feature_channels["stem"] = config.embed_dim
        for i, stage in enumerate(self.stage_names[1:]):
            self.out_feature_channels[stage] = num_features[i]

        # Add layer norms to hidden states of out_features
        hidden_states_norms = {}
        for stage, num_channels in zip(self.out_features, self.channels):
            hidden_states_norms[stage] = nn.LayerNorm(num_channels)
        self.hidden_states_norms = nn.ModuleDict(hidden_states_norms)

        # Initialize weights and apply final processing
        self.post_init()