



from ctypes import c_float, sizeof
from enum import Enum
from typing import TYPE_CHECKING, Optional, Union


if TYPE_CHECKING:
 from .. import AutoFeatureExtractor, AutoProcessor, AutoTokenizer  # tests_ignore


class  _lowercase				(a_ ):
    '''simple docstring'''







    lowercase__				  =  c_float

    @property
    def  _lowerCamelCase   (	self      ):

         '''simple docstring'''


         return sizeof(self.value      )




def 				_lowerCAmelCase      (_lowerCAmelCase				,		_lowerCAmelCase				,		_lowerCAmelCase = 0):
     # < 0 is possible if using a dynamic axis
     if dimension <= 0:
          UpperCamelCase_											=				fixed_dimension

     dimension -= num_token_to_add
     return dimension



def 				_lowerCAmelCase      (_lowerCAmelCase				,		_lowerCAmelCase):
     return num_parameters * dtype.size






def 				_lowerCAmelCase      (_lowerCAmelCase):
     from .. import AutoFeatureExtractor, AutoProcessor, AutoTokenizer  # tests_ignore

     try:
          return AutoProcessor.from_pretrained(_lowerCAmelCase)
     except (ValueError, OSError, KeyError):
          UpperCamelCase_					,      UpperCamelCase_											=				None, None
          try:
               UpperCamelCase_											=				AutoTokenizer.from_pretrained(_lowerCAmelCase)
          except (OSError, KeyError):
               pass
          try:
               UpperCamelCase_											=				AutoFeatureExtractor.from_pretrained(_lowerCAmelCase)
          except (OSError, KeyError):
               pass

          if tokenizer is not None and feature_extractor is not None:
               raise ValueError(
                   f"""Couldn't auto-detect preprocessor for {model_name}. Found both a tokenizer and a feature extractor.""")
          elif tokenizer is None and feature_extractor is None:
               return None
          elif tokenizer is not None:
               return tokenizer
          else:
               return feature_extractor





from typing import TYPE_CHECKING

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


UpperCAmelCase				:							Optional[int]								={
    """configuration_realm""": ["""REALM_PRETRAINED_CONFIG_ARCHIVE_MAP""", """RealmConfig"""],
    """tokenization_realm""": ["""RealmTokenizer"""],
}

try:
	if not is_tokenizers_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	UpperCAmelCase				:							Optional[int]								=["""RealmTokenizerFast"""]

try:
	if not is_torch_available():
		raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
	pass
else:
	UpperCAmelCase				:							Union[str, Any]								=[
	    """REALM_PRETRAINED_MODEL_ARCHIVE_LIST""",
	    """RealmEmbedder""",
	    """RealmForOpenQA""",
	    """RealmKnowledgeAugEncoder""",
	    """RealmPreTrainedModel""",
	    """RealmReader""",
	    """RealmScorer""",
	    """load_tf_weights_in_realm""",
	]
	UpperCAmelCase				:							List[str]								=["""RealmRetriever"""]


if TYPE_CHECKING:
	from .configuration_realm import REALM_PRETRAINED_CONFIG_ARCHIVE_MAP, RealmConfig
	from .tokenization_realm import RealmTokenizer

	try:
		if not is_tokenizers_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .tokenization_realm import RealmTokenizerFast

	try:
		if not is_torch_available():
			raise OptionalDependencyNotAvailable()
	except OptionalDependencyNotAvailable:
		pass
	else:
		from .modeling_realm import (
		    REALM_PRETRAINED_MODEL_ARCHIVE_LIST,
		    RealmEmbedder,
		    RealmForOpenQA,
		    RealmKnowledgeAugEncoder,
		    RealmPreTrainedModel,
		    RealmReader,
		    RealmScorer,
		    load_tf_weights_in_realm,
		)
		from .retrieval_realm import RealmRetriever


else:
	import sys

	UpperCAmelCase				:							str								=_LazyModule(__name__, globals()["""__file__"""], _import_structure, module_spec=__spec__)
