



from typing import TYPE_CHECKING

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


__UpperCAmelCase	       =	{'''configuration_xglm''': ['''XGLM_PRETRAINED_CONFIG_ARCHIVE_MAP''', '''XGLMConfig''']}

try:
    if not is_sentencepiece_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __UpperCAmelCase	       =	['''XGLMTokenizer''']

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

try:
    if not is_torch_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __UpperCAmelCase	       =	[
        '''XGLM_PRETRAINED_MODEL_ARCHIVE_LIST''',
        '''XGLMForCausalLM''',
        '''XGLMModel''',
        '''XGLMPreTrainedModel''',
    ]


try:
    if not is_flax_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __UpperCAmelCase	       =	[
        '''FlaxXGLMForCausalLM''',
        '''FlaxXGLMModel''',
        '''FlaxXGLMPreTrainedModel''',
    ]


try:
    if not is_tf_available():
        raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
    pass
else:
    __UpperCAmelCase	       =	[
        '''TF_XGLM_PRETRAINED_MODEL_ARCHIVE_LIST''',
        '''TFXGLMForCausalLM''',
        '''TFXGLMModel''',
        '''TFXGLMPreTrainedModel''',
    ]


if TYPE_CHECKING:
    from .configuration_xglm import XGLM_PRETRAINED_CONFIG_ARCHIVE_MAP, XGLMConfig

    try:
        if not is_sentencepiece_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .tokenization_xglm import XGLMTokenizer

    try:
        if not is_tokenizers_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .tokenization_xglm_fast import XGLMTokenizerFast

    try:
        if not is_torch_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_xglm import XGLM_PRETRAINED_MODEL_ARCHIVE_LIST, XGLMForCausalLM, XGLMModel, XGLMPreTrainedModel

    try:
        if not is_flax_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_flax_xglm import FlaxXGLMForCausalLM, FlaxXGLMModel, FlaxXGLMPreTrainedModel

    try:
        if not is_tf_available():
            raise OptionalDependencyNotAvailable()
    except OptionalDependencyNotAvailable:
        pass
    else:
        from .modeling_tf_xglm import (
            TF_XGLM_PRETRAINED_MODEL_ARCHIVE_LIST,
            TFXGLMForCausalLM,
            TFXGLMModel,
            TFXGLMPreTrainedModel,
        )


else:
    import sys

    __UpperCAmelCase	       =	_LazyModule(__name__, globals()['''__file__'''], _import_structure)








from typing import Optional

import pyspark

from .. import Features, NamedSplit
from ..download import DownloadMode
from ..packaged_modules.spark.spark import Spark
from .abc import AbstractDatasetReader



class     lowerCAmelCase_		(  a__							):
       def __init__(      self,      SCREAMING_SNAKE_CASE_,      SCREAMING_SNAKE_CASE_ = None,      SCREAMING_SNAKE_CASE_ = None,      SCREAMING_SNAKE_CASE_ = True,      SCREAMING_SNAKE_CASE_ = None,      SCREAMING_SNAKE_CASE_ = False,      SCREAMING_SNAKE_CASE_ = None,      SCREAMING_SNAKE_CASE_ = True,      SCREAMING_SNAKE_CASE_ = "arrow",      **SCREAMING_SNAKE_CASE_,      )					->		int:
          super().__init__(
              split=SCREAMING_SNAKE_CASE_,      features=SCREAMING_SNAKE_CASE_,      cache_dir=SCREAMING_SNAKE_CASE_,      keep_in_memory=SCREAMING_SNAKE_CASE_,      streaming=SCREAMING_SNAKE_CASE_,      **SCREAMING_SNAKE_CASE_,      )
          UpperCamelCase   :  Any						     =     load_from_cache_file
          UpperCamelCase   :  Any						     =     file_format
          UpperCamelCase   :  str						     =     Spark(
              df=SCREAMING_SNAKE_CASE_,      features=SCREAMING_SNAKE_CASE_,      cache_dir=SCREAMING_SNAKE_CASE_,      working_dir=SCREAMING_SNAKE_CASE_,      **SCREAMING_SNAKE_CASE_,      )






       def  snake_case_	(      self	)					->		Tuple:
          if self.streaming:
             return self.builder.as_streaming_dataset(split=self.split	)
          UpperCamelCase   :  Dict						     =     None if self._load_from_cache_file else DownloadMode.FORCE_REDOWNLOAD
          self.builder.download_and_prepare(
              download_mode=SCREAMING_SNAKE_CASE_,      file_format=self._file_format,      )
          return self.builder.as_dataset(split=self.split	)



