





from dataclasses import dataclass, field
from typing import ClassVar, Dict

from ..features import Features, Sequence, Value
from .base import TaskTemplate







@dataclass(frozen=UpperCamelCase__)
class 				__lowerCAmelCase       (    UpperCamelCase__):
      # `task` is not a ClassVar since we want it to be part of the `asdict` output for JSON serialization
      _lowercase				:					str						=			field(default="""question-answering-extractive"""						,				metadata={"""include_in_asdict_even_if_is_default""": True})
      _lowercase				:					ClassVar[Features]						=			Features({"""question""": Value("""string"""), """context""": Value("""string""")})
      _lowercase				:					ClassVar[Features]						=			Features(
          {
              """answers""": Sequence(
                  {
                      """text""": Value("""string"""),
                      """answer_start""": Value("""int32"""),
                  })
          })
      _lowercase				:					str						=			"question"
      _lowercase				:					str						=			"context"
      _lowercase				:					str						=			"answers"







      @property
      def    _lowercase  (    self							)   ->						Dict[str, str]:



        '''simple docstring'''




        return {self.question_column: "question", self.context_column: "context", self.answers_column: "answers"}













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       (    UpperCamelCase__):







      def __init__(    self		,      lowerCAmelCase__		,      lowerCAmelCase__ = None		,      lowerCAmelCase__ = None		,      lowerCAmelCase__ = True		,      lowerCAmelCase__ = None		,      lowerCAmelCase__ = False		,      lowerCAmelCase__ = None		,      lowerCAmelCase__ = True		,      lowerCAmelCase__ = "arrow"		,      **lowerCAmelCase__		,      )   ->						Optional[int]:



        '''simple docstring'''




        super().__init__(
            split=lowerCAmelCase__		,      features=lowerCAmelCase__		,      cache_dir=lowerCAmelCase__		,      keep_in_memory=lowerCAmelCase__		,      streaming=lowerCAmelCase__		,      **lowerCAmelCase__		,      )
        a__	:					int										=load_from_cache_file
        a__	:					Tuple										=file_format
        a__	:					List[Any]										=Spark(
            df=lowerCAmelCase__		,      features=lowerCAmelCase__		,      cache_dir=lowerCAmelCase__		,      working_dir=lowerCAmelCase__		,      **lowerCAmelCase__		,      )







      def    _lowercase  (    self							)   ->						str:



        '''simple docstring'''




        if self.streaming:
          return self.builder.as_streaming_dataset(split=self.split							)
        a__	:					str										=None if self._load_from_cache_file else DownloadMode.FORCE_REDOWNLOAD
        self.builder.download_and_prepare(
            download_mode=lowerCAmelCase__		,      file_format=self._file_format		,      )
        return self.builder.as_dataset(split=self.split							)






