


"""simple docstring"""




from typing import List, Optional, Tuple, Union

from . import logging
from .import_utils import is_torch_available, is_torch_version


if is_torch_available():
					import torch

__magic_name__          =							logging.get_logger(__name__)  # pylint: disable=invalid-name

try:
					from torch._dynamo import allow_in_graph as maybe_allow_in_graph
except (ImportError, ModuleNotFoundError):





					def 			a_   (  cls   :List[Any]    ):
								return cls





def 			a_   (  lowercase__   :str, lowercase__   :Union[str, Any] = None, lowercase__   :List[Any] = None, lowercase__   :Optional[int] = None, lowercase__   :List[Any] = None, ):
			__lowerCamelCase        =			device
			__lowerCamelCase        =			shape[0]

			__lowerCamelCase        =			layout or torch.strided
			__lowerCamelCase        =			device or torch.device("""cpu"""    )

			if generator is not None:
						__lowerCamelCase        =			generator.device.type if not isinstance(lowercase_, lowercase_    ) else generator[0].device.type
						if gen_device_type != device.type and gen_device_type == "cpu":
									__lowerCamelCase        =			"""cpu"""
									if device != "mps":
												logger.info(
												    f'The passed generator was created on \'cpu\' even though a tensor on {device} was expected.'
												    f' Tensors will be created on \'cpu\' and then moved to {device}. Note that one can probably'
												    f' slighly speed up this function by passing a generator that was created on the {device} device.'    )
						elif gen_device_type != device.type and gen_device_type == "cuda":
									raise ValueError(f'Cannot generate a {device} tensor from a generator of type {gen_device_type}.'    )

			if isinstance(lowercase_, lowercase_    ):
						__lowerCamelCase        =			(1,) + shape[1:]
						__lowerCamelCase        =			[
						    torch.randn(lowercase_, generator=generator[i], device=lowercase_, dtype=lowercase_, layout=lowercase_    )
						    for i in range(lowercase_    )
						]
						__lowerCamelCase        =			torch.cat(lowercase_, dim=0    ).to(lowercase_    )
			else:
						__lowerCamelCase        =			torch.randn(lowercase_, generator=lowercase_, device=lowercase_, dtype=lowercase_, layout=lowercase_    ).to(lowercase_    )

			return latents





def 			a_   (  lowercase__   :List[str]    ):







			if is_torch_version("""<""", """2.0.0"""    ) or not hasattr(lowercase_, """_dynamo"""    ):
						return False
			return isinstance(lowercase_, torch._dynamo.eval_frame.OptimizedModule    )








"""simple docstring"""




from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_tf_available, is_torch_available


__magic_name__	:   Optional[Any]          =							{
    'configuration_flaubert': ['FLAUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP', 'FlaubertConfig', 'FlaubertOnnxConfig'],
    'tokenization_flaubert': ['FlaubertTokenizer'],
}

try:
					if not is_torch_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__magic_name__	:   List[Any]          =							[
					    'FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
					    'FlaubertForMultipleChoice',
					    'FlaubertForQuestionAnswering',
					    'FlaubertForQuestionAnsweringSimple',
					    'FlaubertForSequenceClassification',
					    'FlaubertForTokenClassification',
					    'FlaubertModel',
					    'FlaubertWithLMHeadModel',
					    'FlaubertPreTrainedModel',
					]

try:
					if not is_tf_available():
										raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
					pass
else:
					__magic_name__	:   Tuple          =							[
					    'TF_FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST',
					    'TFFlaubertForMultipleChoice',
					    'TFFlaubertForQuestionAnsweringSimple',
					    'TFFlaubertForSequenceClassification',
					    'TFFlaubertForTokenClassification',
					    'TFFlaubertModel',
					    'TFFlaubertPreTrainedModel',
					    'TFFlaubertWithLMHeadModel',
					]


if TYPE_CHECKING:
					from .configuration_flaubert import FLAUBERT_PRETRAINED_CONFIG_ARCHIVE_MAP, FlaubertConfig, FlaubertOnnxConfig
					from .tokenization_flaubert import FlaubertTokenizer

					try:
										if not is_torch_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_flaubert import (
										    FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
										    FlaubertForMultipleChoice,
										    FlaubertForQuestionAnswering,
										    FlaubertForQuestionAnsweringSimple,
										    FlaubertForSequenceClassification,
										    FlaubertForTokenClassification,
										    FlaubertModel,
										    FlaubertPreTrainedModel,
										    FlaubertWithLMHeadModel,
										)

					try:
										if not is_tf_available():
															raise OptionalDependencyNotAvailable()
					except OptionalDependencyNotAvailable:
										pass
					else:
										from .modeling_tf_flaubert import (
										    TF_FLAUBERT_PRETRAINED_MODEL_ARCHIVE_LIST,
										    TFFlaubertForMultipleChoice,
										    TFFlaubertForQuestionAnsweringSimple,
										    TFFlaubertForSequenceClassification,
										    TFFlaubertForTokenClassification,
										    TFFlaubertModel,
										    TFFlaubertPreTrainedModel,
										    TFFlaubertWithLMHeadModel,
										)

else:
					import sys

					__magic_name__	:   List[str]          =							_LazyModule(__name__, globals()['__file__'], _import_structure, module_spec=__spec__)




