



from typing import Callable, Optional, Union

from ...configuration_utils import PretrainedConfig
from ...utils import logging


lowercase_								=     logging.get_logger(__name__)

lowercase_								=     {
    "microsoft/xprophetnet-large-wiki100-cased": (
        "https://huggingface.co/microsoft/xprophetnet-large-wiki100-cased/resolve/main/config.json"
    ),
}
class 				_snake_case			(					_UpperCAmelCase):
    UpperCamelCase__				:					Optional[Any]     		="""xlm-prophetnet"""
    UpperCamelCase__				:					Optional[Any]     		=["""past_key_values"""]
    UpperCamelCase__				:					Optional[Any]     		={
        """num_attention_heads""": """num_encoder_attention_heads""",
    }




    def __init__(						self					:						List[Any],					__lowercase					:						Optional[float] = 0.1,					__lowercase					:						Optional[Union[str, Callable]] = "gelu",					__lowercase					:						Optional[int] = 3_0522,					__lowercase					:						Optional[int] = 1024,					__lowercase					:						Optional[int] = 4096,					__lowercase					:						Optional[int] = 12,					__lowercase					:						Optional[int] = 16,					__lowercase					:						Optional[int] = 4096,					__lowercase					:						Optional[int] = 12,					__lowercase					:						Optional[int] = 16,					__lowercase					:						Optional[float] = 0.1,					__lowercase					:						Optional[float] = 0.1,					__lowercase					:						Optional[int] = 512,					__lowercase					:						Optional[float] = 0.02,					__lowercase					:						Optional[bool] = True,					__lowercase					:						Optional[bool] = True,					__lowercase					:						Optional[int] = 0,					__lowercase					:						Optional[int] = 2,					__lowercase					:						Optional[int] = 32,					__lowercase					:						Optional[int] = 128,					__lowercase					:						Optional[bool] = False,					__lowercase					:						Optional[float] = 0.0,					__lowercase					:						Optional[bool] = True,					__lowercase					:						Optional[int] = 0,					__lowercase					:						Optional[int] = 1,					__lowercase					:						Optional[int] = 2,					**__lowercase					:						List[Any],					):
       lowercase__					  =				vocab_size
       lowercase__					  =				hidden_size
       lowercase__					  =				encoder_ffn_dim
       lowercase__					  =				num_encoder_layers
       lowercase__					  =				num_encoder_attention_heads
       lowercase__					  =				decoder_ffn_dim
       lowercase__					  =				num_decoder_layers
       lowercase__					  =				num_decoder_attention_heads
       lowercase__					  =				max_position_embeddings
       lowercase__					  =				init_std  # Normal(0, this parameter)
       lowercase__					  =				activation_function

       # parameters for xlmprophetnet
       lowercase__					  =				ngram
       lowercase__					  =				num_buckets
       lowercase__					  =				relative_max_distance
       lowercase__					  =				disable_ngram_loss
       lowercase__					  =				eps

       # 3 Types of Dropout
       lowercase__					  =				attention_dropout
       lowercase__					  =				activation_dropout
       lowercase__					  =				dropout

       lowercase__					  =				use_cache

       super().__init__(
           pad_token_id=lowerCamelCase_,					bos_token_id=lowerCamelCase_,					eos_token_id=lowerCamelCase_,					is_encoder_decoder=lowerCamelCase_,					add_cross_attention=lowerCamelCase_,					decoder_start_token_id=lowerCamelCase_,					**lowerCamelCase_,					)




    @property
    def 							A__      (						self					:						List[Any]						):
       return self.num_encoder_layers + self.num_decoder_layers




    @num_hidden_layers.setter
    def 							A__      (						self					:						Union[str, Any],					__lowercase					:						Optional[Any]						):
       raise NotImplementedError(
           "This model does not support the setting of `num_hidden_layers`. Please set `num_encoder_layers` and"
           " `num_decoder_layers`."						)









# Copyright 2023 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 typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


lowercase_								=     {
    """configuration_xmod""": [
        """XMOD_PRETRAINED_CONFIG_ARCHIVE_MAP""",
        """XmodConfig""",
        """XmodOnnxConfig""",
    ],
}

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							lowercase_								=     [
							    """XMOD_PRETRAINED_MODEL_ARCHIVE_LIST""",
							    """XmodForCausalLM""",
							    """XmodForMaskedLM""",
							    """XmodForMultipleChoice""",
							    """XmodForQuestionAnswering""",
							    """XmodForSequenceClassification""",
							    """XmodForTokenClassification""",
							    """XmodModel""",
							    """XmodPreTrainedModel""",
							]

if TYPE_CHECKING:
							from .configuration_xmod import XMOD_PRETRAINED_CONFIG_ARCHIVE_MAP, XmodConfig, XmodOnnxConfig

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_xmod import (
														    XMOD_PRETRAINED_MODEL_ARCHIVE_LIST,
														    XmodForCausalLM,
														    XmodForMaskedLM,
														    XmodForMultipleChoice,
														    XmodForQuestionAnswering,
														    XmodForSequenceClassification,
														    XmodForTokenClassification,
														    XmodModel,
														    XmodPreTrainedModel,
														)

else:
							import sys

							lowercase_								=     _LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)




