#                🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
#           This file was automatically generated from src/transformers/models/pp_ocrv5_server_rec/modular_pp_ocrv5_server_rec.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_pp_ocrv5_server_rec.py file directly. One of our CI enforces this.
#                🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨
# Copyright 2026 The PaddlePaddle Team and The HuggingFace Inc. 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 ...backbone_utils import consolidate_backbone_kwargs_to_config
from ...configuration_utils import PreTrainedConfig
from ...utils import auto_docstring
from ..auto import AutoConfig


@auto_docstring(checkpoint="PaddlePaddle/PP-OCRv5_server_rec_safetensors")
@strict
class PPOCRV5ServerRecConfig(PreTrainedConfig):
    r"""
    head_out_channels (`int`, *optional*, defaults to 18385):
        The number of output channels from the PPOCRV5ServerRecHead, responsible for final classification.
    """

    model_type = "pp_ocrv5_server_rec"
    sub_configs = {"backbone_config": AutoConfig}

    hidden_act: str = "silu"
    backbone_config: dict | PreTrainedConfig | None = None
    hidden_size: int = 120
    mlp_ratio: float = 2.0
    depth: int = 2
    head_out_channels: int = 18385
    conv_kernel_size: list | None = None
    qkv_bias: bool = True
    num_attention_heads: int = 8
    attention_dropout: float = 0.0
    layer_norm_eps: float = 1e-6

    def __post_init__(self, **kwargs):
        if self.conv_kernel_size is None:
            self.conv_kernel_size = [1, 3]
        self.backbone_config, kwargs = consolidate_backbone_kwargs_to_config(
            backbone_config=self.backbone_config,
            default_config_type="hgnet_v2",
            default_config_kwargs={
                "arch": "L",
                "return_idx": [0, 1, 2, 3],
                "freeze_stem_only": True,
                "freeze_at": 0,
                "freeze_norm": True,
                "lr_mult_list": [1.0, 1.0, 1.0, 1.0, 1.0],
                "out_features": ["stage1", "stage2", "stage3", "stage4"],
                "stage_downsample": [True, True, True, True],
                "stem_strides": [2, 1, 1, 1, 1],
                "stage_downsample_strides": [[2, 1], [1, 2], [2, 1], [2, 1]],
            },
            **kwargs,
        )
        super().__post_init__(**kwargs)


__all__ = ["PPOCRV5ServerRecConfig"]
