#                🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
#           This file was automatically generated from src/transformers/models/kimi_k25/modular_kimi_k25.py.
#               Do NOT edit this file manually as any edits will be overwritten by the generation of
#             the file from the modular. If any change should be done, please apply the change to the
#                          modular_kimi_k25.py file directly. One of our CI enforces this.
#                🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
# Copyright 2026 the HuggingFace Team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from huggingface_hub.dataclasses import strict

from ...configuration_utils import PreTrainedConfig
from ...utils import auto_docstring
from ..auto import CONFIG_MAPPING, AutoConfig


@auto_docstring(checkpoint="moonshotai/Kimi-K2.6")
@strict
class Kimi_K25VisionConfig(PreTrainedConfig):
    r"""
    pos_emb_height (`int`, *optional*):
        Initial position embedding height.
    pos_emb_width (`int`, *optional*):
        Initial position embedding width.
    pos_emb_time (`int`, *optional*):
        Initial position embedding time dimension.
    merge_kernel_size (`tuple[int] | list[int]`, *optional*):
        Kernel size for patch merging.
    """

    model_type = "kimi_k25_vision"

    patch_size: int = 14
    pos_emb_height: int = 64
    pos_emb_width: int = 64
    pos_emb_time: int = 4
    num_attention_heads: int = 16
    num_hidden_layers: int = 27
    hidden_size: int = 1152
    intermediate_size: int = 4304
    hidden_act: str = "gelu_pytorch_tanh"
    merge_kernel_size: tuple[int, int] | list[int] = (2, 2)
    rope_parameters: dict | None = None  # defaults set by `RopeConfigMixin`
    max_position_embeddings: int | None = None


@auto_docstring(checkpoint="moonshotai/Kimi-K2.6")
@strict
class Kimi_K25Config(PreTrainedConfig):
    r"""
    projection_hidden_size (`int`, *optional*, defaults to `1152`):
        The output hidden size for multimodal projector.
    projection_layer_norm_eps (`float`, *optional*, defaults to `1e-5`):
        Layer norm epsilon for projector.
    """

    model_type = "kimi_k25"
    sub_configs = {"text_config": AutoConfig, "vision_config": Kimi_K25VisionConfig}

    text_config: dict | PreTrainedConfig | None = None
    vision_config: dict | PreTrainedConfig | None = None
    projection_hidden_size: int | None = 1152
    projection_layer_norm_eps: float = 1e-5
    image_token_id: int = 163605
    video_token_id: int = 163840
    vision_start_token_id: int = 163602
    vision_end_token_id: int = 163604
    tie_word_embeddings: bool = True

    def __post_init__(self, **kwargs):
        # BC: load from remote config on the hub where the model-type points to remote config
        if isinstance(self.text_config, dict):
            model_type = self.text_config.get("model_type", "deepseek_v3")
            if model_type == "kimi_k2":
                model_type = "deepseek_v3"
            self.text_config = CONFIG_MAPPING[model_type](**self.text_config)
        elif self.text_config is None:
            self.text_config = CONFIG_MAPPING["deepseek_v3"]()
        else:
            model_type = self.text_config.model_type
            if model_type == "kimi_k2":
                self.text_config.model_type = "deepseek_v3"

        if isinstance(self.vision_config, dict):
            self.vision_config = Kimi_K25VisionConfig(**self.vision_config)
        elif self.vision_config is None:
            self.vision_config = Kimi_K25VisionConfig()
        super().__post_init__(**kwargs)


__all__ = ["Kimi_K25Config", "Kimi_K25VisionConfig"]
