
from collections.abc import Iterator, MutableMapping
from dataclasses import dataclass
from typing import Generic, TypeVar

UpperCAmelCase__		:     Dict     			=      TypeVar('KEY')
UpperCAmelCase__		:     Dict     			=      TypeVar('VAL')






@dataclass(frozen=SCREAMING_SNAKE_CASE__							,							slots=SCREAMING_SNAKE_CASE__   )
class UpperCAmelCase   (						Generic[KEY, VAL]   ):





   '''simple docstring'''
   __UpperCamelCase		:    KEY
   __UpperCamelCase		:    VAL






class UpperCAmelCase   (						_Item   ):





   '''simple docstring'''


   def __init__(					self     :							Optional[int]     ):

      """simple docstring"""
      super().__init__(lowerCAmelCase_			,			lowerCAmelCase_     )


   def __bool__(					self     :							List[str]     ):

      """simple docstring"""
      return False

UpperCAmelCase__		:     Tuple     			=      _DeletedItem()






class UpperCAmelCase   (						MutableMapping[KEY, VAL]   ):





   '''simple docstring'''


   def __init__(					self     :							List[str]			,			lowerCAmelCase_     :							int = 8			,			lowerCAmelCase_     :							float = 0.75     ):

      """simple docstring"""
      _A:  Tuple					=       initial_block_size
      _A:  list[_Item | None]					=       [None] * initial_block_size
      assert 0.0 < capacity_factor < 1.0
      _A:  Optional[Any]					=       capacity_factor
      _A:  Optional[Any]					=       0


   def  __magic_name__				(					self     :							Optional[int]			,			lowerCAmelCase_     :							KEY     ):

      """simple docstring"""
      return hash(lowerCAmelCase_     ) % len(self._buckets     )


   def  __magic_name__				(					self     :							Dict			,			lowerCAmelCase_     :							int     ):

      """simple docstring"""
      return (ind + 1) % len(self._buckets     )


   def  __magic_name__				(					self     :							List[Any]			,			lowerCAmelCase_     :							int			,			lowerCAmelCase_     :							KEY			,			lowerCAmelCase_     :							VAL     ):

      """simple docstring"""
      _A:  Optional[int]					=       self._buckets[ind]
      if not stored:
         _A:  Tuple					=       _Item(lowerCAmelCase_			,			lowerCAmelCase_     )
         self._len += 1
         return True
      elif stored.key == key:
         _A:  Optional[int]					=       _Item(lowerCAmelCase_			,			lowerCAmelCase_     )
         return True
      else:
         return False


   def  __magic_name__				(					self     :							List[Any]     ):

      """simple docstring"""
      _A:  Tuple					=       len(self._buckets     ) * self._capacity_factor
      return len(self     ) >= int(lowerCAmelCase_     )


   def  __magic_name__				(					self     :							Optional[Any]     ):

      """simple docstring"""
      if len(self._buckets     ) <= self._initial_block_size:
         return False
      _A:  List[Any]					=       len(self._buckets     ) * self._capacity_factor / 2
      return len(self     ) < limit


   def  __magic_name__				(					self     :							Optional[int]			,			lowerCAmelCase_     :							int     ):

      """simple docstring"""
      _A:  Optional[int]					=       self._buckets
      _A:  Dict					=       [None] * new_size
      _A:  Optional[Any]					=       0
      for item in old_buckets:
         if item:
            self._add_item(item.key			,			item.val     )


   def  __magic_name__				(					self     :							Union[str, Any]     ):

      """simple docstring"""
      self._resize(len(self._buckets     ) * 2     )


   def  __magic_name__				(					self     :							Optional[Any]     ):

      """simple docstring"""
      self._resize(len(self._buckets     ) // 2     )


   def  __magic_name__				(					self     :							str			,			lowerCAmelCase_     :							KEY     ):

      """simple docstring"""
      _A:  List[str]					=       self._get_bucket_index(lowerCAmelCase_     )
      for _ in range(len(self._buckets     )     ):
         yield ind
         _A:  List[Any]					=       self._get_next_ind(lowerCAmelCase_     )


   def  __magic_name__				(					self     :							int			,			lowerCAmelCase_     :							KEY			,			lowerCAmelCase_     :							VAL     ):

      """simple docstring"""
      for ind in self._iterate_buckets(lowerCAmelCase_     ):
         if self._try_set(lowerCAmelCase_			,			lowerCAmelCase_			,			lowerCAmelCase_     ):
            break


   def __setitem__(					self     :							List[str]			,			lowerCAmelCase_     :							KEY			,			lowerCAmelCase_     :							VAL     ):

      """simple docstring"""
      if self._is_full():
         self._size_up()

      self._add_item(lowerCAmelCase_			,			lowerCAmelCase_     )


   def __delitem__(					self     :							Union[str, Any]			,			lowerCAmelCase_     :							KEY     ):

      """simple docstring"""
      for ind in self._iterate_buckets(lowerCAmelCase_     ):
         _A:  List[Any]					=       self._buckets[ind]
         if item is None:
            raise KeyError(lowerCAmelCase_     )
         if item is _deleted:
            continue
         if item.key == key:
            _A:  Optional[int]					=       _deleted
            self._len -= 1
            break
      if self._is_sparse():
         self._size_down()


   def __getitem__(					self     :							List[str]			,			lowerCAmelCase_     :							KEY     ):

      """simple docstring"""
      for ind in self._iterate_buckets(lowerCAmelCase_     ):
         _A:  Tuple					=       self._buckets[ind]
         if item is None:
            break
         if item is _deleted:
            continue
         if item.key == key:
            return item.val
      raise KeyError(lowerCAmelCase_     )


   def __len__(					self     :							Union[str, Any]     ):

      """simple docstring"""
      return self._len


   def __iter__(					self     :							Dict     ):

      """simple docstring"""
      yield from (item.key for item in self._buckets if item)


   def __repr__(					self     :							List[Any]     ):

      """simple docstring"""
      _A:  Optional[Any]					=       ''' ,'''.join(
          F"""{item.key}: {item.val}""" for item in self._buckets if item     )
      return F"""HashMap({val_string})"""





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

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






@dataclass(frozen=SCREAMING_SNAKE_CASE__   )
class UpperCAmelCase   (						SCREAMING_SNAKE_CASE__   ):





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


   @property
   def  __magic_name__				(					self     :							List[str]     ):

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



