





'''simple docstring'''






import itertools
from dataclasses import dataclass
from typing import Optional

import pandas as pd
import pyarrow as pa

import datasets
from datasets.table import table_cast






@dataclass
class        __snake_case	(       datasets.BuilderConfig):







    """simple docstring"""



    lowercase       			= None







class        __snake_case	(       datasets.ArrowBasedBuilder):







    """simple docstring"""



    lowercase       			= PandasConfig

    def __lowercase       (       self   :  List[Any]		)       ->  int:
      return datasets.DatasetInfo(features=self.config.features		)

    def __lowercase       (       self   :  Any   ,						lowerCamelCase   :  int		)       ->  List[str]:


      if not self.config.data_files:
        raise ValueError(F'At least one data file must be specified, but got data_files={self.config.data_files}'		)
      lowerCAmelCase_      :				Union[str, Any]      =       dl_manager.download_and_extract(self.config.data_files		)
      if isinstance(UpperCamelCase__   ,						(str, list, tuple)		):
        lowerCAmelCase_      :				Optional[Any]      =       data_files
        if isinstance(UpperCamelCase__   ,						UpperCamelCase__		):
          lowerCAmelCase_      :				int      =       [files]
        # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
        lowerCAmelCase_      :				int      =       [dl_manager.iter_files(UpperCamelCase__		) for file in files]
        return [datasets.SplitGenerator(name=datasets.Split.TRAIN   ,						gen_kwargs={"""files""": files}		)]
      lowerCAmelCase_      :				Tuple      =       []
      for split_name, files in data_files.items():
        if isinstance(UpperCamelCase__   ,						UpperCamelCase__		):
          lowerCAmelCase_      :				List[str]      =       [files]
        # Use `dl_manager.iter_files` to skip hidden files in an extracted archive
        lowerCAmelCase_      :				int      =       [dl_manager.iter_files(UpperCamelCase__		) for file in files]
        splits.append(datasets.SplitGenerator(name=UpperCamelCase__   ,						gen_kwargs={"""files""": files}		)		)
      return splits

    def __lowercase       (       self   :  Optional[int]   ,						lowerCamelCase   :  pa.Table		)       ->  pa.Table:


      if self.config.features is not None:
        # more expensive cast to support nested features with keys in a different order
        # allows str <-> int/float or str to Audio for example
        lowerCAmelCase_      :				Dict      =       table_cast(UpperCamelCase__   ,						self.config.features.arrow_schema		)
      return pa_table





    def __lowercase       (       self   :  Optional[int]   ,						lowerCamelCase   :  Tuple		)       ->  List[str]:


      for i, file in enumerate(itertools.chain.from_iterable(UpperCamelCase__		)		):
        with open(UpperCamelCase__   ,						"""rb"""		) as f:
          lowerCAmelCase_      :				str      =       pa.Table.from_pandas(pd.read_pickle(UpperCamelCase__		)		)
          yield i, self._cast_table(UpperCamelCase__		)







'''simple docstring'''






from typing import TYPE_CHECKING

from ...utils import OptionalDependencyNotAvailable, _LazyModule, is_torch_available


__A :  List[str]    							=				{
    "configuration_bigbird_pegasus": [
        "BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP",
        "BigBirdPegasusConfig",
        "BigBirdPegasusOnnxConfig",
    ],
}

try:
  if not is_torch_available():
    raise OptionalDependencyNotAvailable()
except OptionalDependencyNotAvailable:
  pass
else:
  __A :  Union[str, Any]    							=				[
      "BIGBIRD_PEGASUS_PRETRAINED_MODEL_ARCHIVE_LIST",
      "BigBirdPegasusForCausalLM",
      "BigBirdPegasusForConditionalGeneration",
      "BigBirdPegasusForQuestionAnswering",
      "BigBirdPegasusForSequenceClassification",
      "BigBirdPegasusModel",
      "BigBirdPegasusPreTrainedModel",
  ]


if TYPE_CHECKING:
  from .configuration_bigbird_pegasus import (
      BIGBIRD_PEGASUS_PRETRAINED_CONFIG_ARCHIVE_MAP,
      BigBirdPegasusConfig,
      BigBirdPegasusOnnxConfig,
  )

  try:
    if not is_torch_available():
      raise OptionalDependencyNotAvailable()
  except OptionalDependencyNotAvailable:
    pass
  else:
    from .modeling_bigbird_pegasus import (
        BIGBIRD_PEGASUS_PRETRAINED_MODEL_ARCHIVE_LIST,
        BigBirdPegasusForCausalLM,
        BigBirdPegasusForConditionalGeneration,
        BigBirdPegasusForQuestionAnswering,
        BigBirdPegasusForSequenceClassification,
        BigBirdPegasusModel,
        BigBirdPegasusPreTrainedModel,
    )


else:
  import sys

  __A :  List[Any]    							=				_LazyModule(__name__, globals()["__file__"], _import_structure, module_spec=__spec__)



