





"""simple docstring"""





from typing import TYPE_CHECKING

from ...utils import (
    OptionalDependencyNotAvailable,
    _LazyModule,
    is_flax_available,
    is_tf_available,
    is_tokenizers_available,
    is_torch_available,
)


_UpperCamelCase					      =   {
    'configuration_distilbert': [
        'DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP',
        'DistilBertConfig',
        'DistilBertOnnxConfig',
    ],
    'tokenization_distilbert': ['DistilBertTokenizer'],
}

try:
							if not is_tokenizers_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							_UpperCamelCase					      =   ['DistilBertTokenizerFast']

try:
							if not is_torch_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							_UpperCamelCase					      =   [
							    'DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
							    'DistilBertForMaskedLM',
							    'DistilBertForMultipleChoice',
							    'DistilBertForQuestionAnswering',
							    'DistilBertForSequenceClassification',
							    'DistilBertForTokenClassification',
							    'DistilBertModel',
							    'DistilBertPreTrainedModel',
							]

try:
							if not is_tf_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							_UpperCamelCase					      =   [
							    'TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
							    'TFDistilBertForMaskedLM',
							    'TFDistilBertForMultipleChoice',
							    'TFDistilBertForQuestionAnswering',
							    'TFDistilBertForSequenceClassification',
							    'TFDistilBertForTokenClassification',
							    'TFDistilBertMainLayer',
							    'TFDistilBertModel',
							    'TFDistilBertPreTrainedModel',
							]

try:
							if not is_flax_available():
														raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
							pass
else:
							_UpperCamelCase					      =   [
							    'FlaxDistilBertForMaskedLM',
							    'FlaxDistilBertForMultipleChoice',
							    'FlaxDistilBertForQuestionAnswering',
							    'FlaxDistilBertForSequenceClassification',
							    'FlaxDistilBertForTokenClassification',
							    'FlaxDistilBertModel',
							    'FlaxDistilBertPreTrainedModel',
							]


if TYPE_CHECKING:
							from .configuration_distilbert import (
							    DISTILBERT_PRETRAINED_CONFIG_ARCHIVE_MAP,
							    DistilBertConfig,
							    DistilBertOnnxConfig,
							)
							from .tokenization_distilbert import DistilBertTokenizer

							try:
														if not is_tokenizers_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .tokenization_distilbert_fast import DistilBertTokenizerFast

							try:
														if not is_torch_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_distilbert import (
														    DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
														    DistilBertForMaskedLM,
														    DistilBertForMultipleChoice,
														    DistilBertForQuestionAnswering,
														    DistilBertForSequenceClassification,
														    DistilBertForTokenClassification,
														    DistilBertModel,
														    DistilBertPreTrainedModel,
														)

							try:
														if not is_tf_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_tf_distilbert import (
														    TF_DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
														    TFDistilBertForMaskedLM,
														    TFDistilBertForMultipleChoice,
														    TFDistilBertForQuestionAnswering,
														    TFDistilBertForSequenceClassification,
														    TFDistilBertForTokenClassification,
														    TFDistilBertMainLayer,
														    TFDistilBertModel,
														    TFDistilBertPreTrainedModel,
														)

							try:
														if not is_flax_available():
																					raise OptionalDependencyNotAvailable()
							except OptionalDependencyNotAvailable:
														pass
							else:
														from .modeling_flax_distilbert import (
														    FlaxDistilBertForMaskedLM,
														    FlaxDistilBertForMultipleChoice,
														    FlaxDistilBertForQuestionAnswering,
														    FlaxDistilBertForSequenceClassification,
														    FlaxDistilBertForTokenClassification,
														    FlaxDistilBertModel,
														    FlaxDistilBertPreTrainedModel,
														)

else:
							import sys

							_UpperCamelCase					      =   _LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)











"""simple docstring"""





from __future__ import annotations

import unittest

from transformers import is_tf_available
from transformers.testing_utils import require_sentencepiece, require_tf, require_tokenizers, slow


if is_tf_available():
							import numpy as np
							import tensorflow as tf

							from transformers import TFXLMRobertaModel
@require_tf
@require_sentencepiece
@require_tokenizers
class 		SCREAMING_SNAKE_CASE_				(     unittest.TestCase ):
				"""simple docstring"""




				@slow
				def        __lowercase	(  self	:Union[str, Any]      ):
											__lowerCamelCase   :   List[Any]       =TFXLMRobertaModel.from_pretrained('''jplu/tf-xlm-roberta-base'''      )

											__lowerCamelCase   :   Dict       ={
											    '''input_ids''': tf.convert_to_tensor([[0, 2646, 1_0269, 83, 9_9942, 2]]    ,     dtype=tf.intaa      ),  # "My dog is cute"
											    '''attention_mask''': tf.convert_to_tensor([[1, 1, 1, 1, 1, 1]]    ,     dtype=tf.intaa      ),
											}

											__lowerCamelCase   :   Optional[int]       =model(__lowercase      )['''last_hidden_state''']
											__lowerCamelCase   :   str       =tf.TensorShape((1, 6, 768)      )
											self.assertEqual(output.shape    ,     __lowercase      )
											# compare the actual values for a slice.
											__lowerCamelCase   :   str       =tf.convert_to_tensor(
											    [
											        [
											            [0.0681762, 0.10894451, 0.06772504],
											            [-0.06423668, 0.02366615, 0.04329344],
											            [-0.06057295, 0.09974135, -0.00070584],
											        ]
											    ]    ,     dtype=tf.floataa    ,     )

											self.assertTrue(np.allclose(output[:, :3, :3].numpy()    ,     expected_slice.numpy()    ,     atol=1e-4      )      )




