Repository: huggingface/transformers
File: src/transformers/models/dia/configuration_dia.py (Python)

Code before:
        self,
        encoder_config: DiaEncoderConfig | None = None,
        decoder_config: DiaDecoderConfig | None = None,
        norm_eps: float = 1e-5,
        is_encoder_decoder: bool = True,
        pad_token_id: int = 1025,
        eos_token_id: int = 1024,
        bos_token_id: int = 1026,
        delay_pattern: list[int] | None = None,
        initializer_range: float = 0.02,
        use_cache: bool = True,
        **kwargs,
    ):
        if isinstance(encoder_config, dict):
            encoder_config = DiaEncoderConfig(**encoder_config)
        if isinstance(decoder_config, dict):
            decoder_config = DiaDecoderConfig(**decoder_config)
        self.encoder_config = encoder_config if encoder_config is not None else DiaEncoderConfig()
        self.decoder_config = decoder_config if decoder_config is not None else DiaDecoderConfig()
        self.norm_eps = norm_eps
        self.delay_pattern = delay_pattern if delay_pattern is not None else [0, 8, 9, 10, 11, 12, 13, 14, 15]
        self.initializer_range = initializer_range
        self.use_cache = use_cache
        self.pad_token_id = pad_token_id
        self.eos_token_id = eos_token_id
        self.bos_token_id = bos_token_id
        self.decoder_config.pad_token_id = pad_token_id
        self.decoder_config.eos_token_id = eos_token_id
        self.decoder_config.bos_token_id = bos_token_id

        assert self.decoder_config.num_channels == len(self.delay_pattern), (
            "Number of channels must match delay pattern length."
        )

        super().__init__(is_encoder_decoder=is_encoder_decoder, **kwargs)

    def get_text_config(self, *args, **kwargs):
        """Defaulting to audio config as it's the decoder in this case which is usually the text backbone"""
        return self.decoder_config


__all__ = ["DiaConfig", "DiaEncoderConfig", "DiaDecoderConfig"]


Review comment (suggestion):
imo we need to remote `pad_token_id: int = 1025, eos_token_id: int = 1024, bos_token_id: int = 1026` in longer term. They have to be in the config where it's actually set as attr

For BC we can keep it and set default to `None`, that should work since `save_pretrained` wasn't saving it anyway in the main config. So smth like

python
```
def __init__(self,
pad_token_id: int = None,
        eos_token_id: int = None,
        bos_token_id: int = None,

# We could raise a deprecation warning here, but first we need to update the official ckpt in `nari-labs` org
if pad_token_id is not None:
    logger.maybe_warn("Please pass you pad token to the config where it belongs!")
    self.decoder_config.pad_token_id = pad_token_id

```

Code after:
    >>> configuration = DiaConfig()

    >>> # Initializing a DiaModel (with random weights) from the configuration
    >>> model = DiaModel(configuration)

    >>> # Accessing the model configuration
    >>> configuration = model.config
    ```
    """

    model_type = "dia"
    keys_to_ignore_at_inference = ["past_key_values"]
    sub_configs = {"encoder_config": DiaEncoderConfig, "decoder_config": DiaDecoderConfig}

    def __init__(
        self,
        encoder_config: DiaEncoderConfig | None = None,
        decoder_config: DiaDecoderConfig | None = None,
        norm_eps: float = 1e-5,
        is_encoder_decoder: bool = True,
        pad_token_id: int | None = None,
        eos_token_id: int | None = None,
        bos_token_id: int | None = None,
        delay_pattern: list[int] | None = None,
        initializer_range: float = 0.02,
        use_cache: bool = True,
        **kwargs,
    ):
        if isinstance(encoder_config, dict):
            encoder_config = DiaEncoderConfig(**encoder_config)
        if isinstance(decoder_config, dict):
            decoder_config = DiaDecoderConfig(**decoder_config)
        self.encoder_config = encoder_config if encoder_config is not None else DiaEncoderConfig()
        self.decoder_config = decoder_config if decoder_config is not None else DiaDecoderConfig()
        self.norm_eps = norm_eps
        self.delay_pattern = delay_pattern if delay_pattern is not None else [0, 8, 9, 10, 11, 12, 13, 14, 15]
        self.initializer_range = initializer_range
        self.use_cache = use_cache

        # TODO: Remove token ID forwarding once the `nari-labs/Dia-1.6B`
        # checkpoint is updated
        if pad_token_id is not None:
            logger.warning_once(
                "Passing `pad_token_id` to `DiaConfig` is deprecated. "
                "Please set it directly on `DiaDecoderConfig` instead."
            )
            self.decoder_config.pad_token_id = pad_token_id
        if eos_token_id is not None:
            logger.warning_once(
                "Passing `eos_token_id` to `DiaConfig` is deprecated. "
                "Please set it directly on `DiaDecoderConfig` instead."