




'''simple docstring'''


from ...configuration_utils import PretrainedConfig
from ...utils import logging


UpperCAmelCase_ 		=      logging.get_logger(__name__)

UpperCAmelCase_ 		=      {
    "funnel-transformer/small": "https://huggingface.co/funnel-transformer/small/resolve/main/config.json",
    "funnel-transformer/small-base": "https://huggingface.co/funnel-transformer/small-base/resolve/main/config.json",
    "funnel-transformer/medium": "https://huggingface.co/funnel-transformer/medium/resolve/main/config.json",
    "funnel-transformer/medium-base": "https://huggingface.co/funnel-transformer/medium-base/resolve/main/config.json",
    "funnel-transformer/intermediate": (
        "https://huggingface.co/funnel-transformer/intermediate/resolve/main/config.json"
    ),
    "funnel-transformer/intermediate-base": (
        "https://huggingface.co/funnel-transformer/intermediate-base/resolve/main/config.json"
    ),
    "funnel-transformer/large": "https://huggingface.co/funnel-transformer/large/resolve/main/config.json",
    "funnel-transformer/large-base": "https://huggingface.co/funnel-transformer/large-base/resolve/main/config.json",
    "funnel-transformer/xlarge": "https://huggingface.co/funnel-transformer/xlarge/resolve/main/config.json",
    "funnel-transformer/xlarge-base": "https://huggingface.co/funnel-transformer/xlarge-base/resolve/main/config.json",
}





class    __lowercase						(  __SCREAMING_SNAKE_CASE ):
   _a							=      """funnel"""
   _a							=      {
       """hidden_size""": """d_model""",
       """num_attention_heads""": """n_head""",
   }







   def __init__(	self      ,							UpperCamelCase=3_0522      ,							UpperCamelCase=[4, 4, 4]      ,							UpperCamelCase=None      ,							UpperCamelCase=2      ,							UpperCamelCase=768      ,							UpperCamelCase=12      ,							UpperCamelCase=64      ,							UpperCamelCase=3072      ,							UpperCamelCase="gelu_new"      ,							UpperCamelCase=0.1      ,							UpperCamelCase=0.1      ,							UpperCamelCase=0.0      ,							UpperCamelCase=0.1      ,							UpperCamelCase=None      ,							UpperCamelCase=1e-9      ,							UpperCamelCase="mean"      ,							UpperCamelCase="relative_shift"      ,							UpperCamelCase=True      ,							UpperCamelCase=True      ,							UpperCamelCase=True      ,							**UpperCamelCase      ,							)				->    Union[str, Any]:
     __a			=					vocab_size
     __a			=					block_sizes
     __a			=					[1] * len(__snake_case      ) if block_repeats is None else block_repeats
     assert len(__snake_case      ) == len(
         self.block_repeats      ), "`block_sizes` and `block_repeats` should have the same length."
     __a			=					num_decoder_layers
     __a			=					d_model
     __a			=					n_head
     __a			=					d_head
     __a			=					d_inner
     __a			=					hidden_act
     __a			=					hidden_dropout
     __a			=					attention_dropout
     __a			=					activation_dropout
     __a			=					initializer_range
     __a			=					initializer_std
     __a			=					layer_norm_eps
     assert pooling_type in [
         "mean",
         "max",
     ], f"Got {pooling_type} for `pooling_type` but only 'mean' and 'max' are supported."
     __a			=					pooling_type
     assert attention_type in [
         "relative_shift",
         "factorized",
     ], f"Got {attention_type} for `attention_type` but only 'relative_shift' and 'factorized' are supported."
     __a			=					attention_type
     __a			=					separate_cls
     __a			=					truncate_seq
     __a			=					pool_q_only

     super().__init__(**__snake_case      )







   @property
   def 		UpperCamelCase__			(	self      )				->    int:
     return sum(self.block_sizes      )







   @num_hidden_layers.setter
   def 		UpperCamelCase__			(	self      ,							UpperCamelCase      )				->    Optional[int]:
     raise NotImplementedError(
         'This model does not support the setting of `num_hidden_layers`. Please set `block_sizes`.'      )







   @property
   def 		UpperCamelCase__			(	self      )				->    int:
     return len(self.block_sizes      )







   @num_blocks.setter
   def 		UpperCamelCase__			(	self      ,							UpperCamelCase      )				->    Optional[int]:
     raise NotImplementedError('This model does not support the setting of `num_blocks`. Please set `block_sizes`.'      )








'''simple docstring'''


from typing import List, Optional, TypeVar

from .arrow_dataset import Dataset, _concatenate_map_style_datasets, _interleave_map_style_datasets
from .dataset_dict import DatasetDict, IterableDatasetDict
from .info import DatasetInfo
from .iterable_dataset import IterableDataset, _concatenate_iterable_datasets, _interleave_iterable_datasets
from .splits import NamedSplit
from .utils import logging
from .utils.py_utils import Literal


UpperCAmelCase_ 		=      logging.get_logger(__name__)


UpperCAmelCase_ 		=      TypeVar("DatasetType", Dataset, IterableDataset)


def 						SCREAMING_SNAKE_CASE       (      a_	:							List[DatasetType]				,					a_	:							Optional[List[float]] = None				,					a_	:							Optional[int] = None				,					a_	:							Optional[DatasetInfo] = None				,					a_	:							Optional[NamedSplit] = None				,					a_	:							Literal["first_exhausted", "all_exhausted"] = "first_exhausted"				,					):
  from .arrow_dataset import Dataset
  from .iterable_dataset import IterableDataset

  if not datasets:
    raise ValueError('Unable to interleave an empty list of datasets.'			)
  for i, dataset in enumerate(a_			):
    if not isinstance(a_				,					(Dataset, IterableDataset)			):
      if isinstance(a_				,					(DatasetDict, IterableDatasetDict)			):
        if not dataset:
          raise ValueError(
              f"Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} "
              'is an empty dataset dictionary.'			)
        raise ValueError(
            f"Dataset at position {i} has at least one split: {list(a_			)}\n"
            f"Please pick one to interleave with the other datasets, for example: dataset['{next(iter(a_			)			)}']"			)
      raise ValueError(
          f"Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} is a {type(a_			).__name__}."			)
    if i == 0:
      __a	,       __a			=					(
          (Dataset, IterableDataset) if isinstance(a_				,					a_			) else (IterableDataset, Dataset)
      )
    elif not isinstance(a_				,					a_			):
      raise ValueError(
          f"Unable to interleave a {dataset_type.__name__} (at position 0) with a {other_type.__name__} (at position {i}). Expected a list of Dataset objects or a list of IterableDataset objects."			)
  if stopping_strategy not in ["first_exhausted", "all_exhausted"]:
    raise ValueError(f"{stopping_strategy} is not supported. Please enter a valid stopping_strategy."			)
  if dataset_type is Dataset:
    return _interleave_map_style_datasets(
        a_				,					a_				,					a_				,					info=a_				,					split=a_				,					stopping_strategy=a_			)
  else:
    return _interleave_iterable_datasets(
        a_				,					a_				,					a_				,					info=a_				,					split=a_				,					stopping_strategy=a_			)


def 						SCREAMING_SNAKE_CASE       (      a_	:							List[DatasetType]				,					a_	:							Optional[DatasetInfo] = None				,					a_	:							Optional[NamedSplit] = None				,					a_	:							int = 0				,					):

  if not dsets:
    raise ValueError('Unable to concatenate an empty list of datasets.'			)
  for i, dataset in enumerate(a_			):
    if not isinstance(a_				,					(Dataset, IterableDataset)			):
      if isinstance(a_				,					(DatasetDict, IterableDatasetDict)			):
        if not dataset:
          raise ValueError(
              f"Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} "
              'is an empty dataset dictionary.'			)
        raise ValueError(
            f"Dataset at position {i} has at least one split: {list(a_			)}\n"
            f"Please pick one to interleave with the other datasets, for example: dataset['{next(iter(a_			)			)}']"			)
      raise ValueError(
          f"Expected a list of Dataset objects or a list of IterableDataset objects, but element at position {i} is a {type(a_			).__name__}."			)
    if i == 0:
      __a	,       __a			=					(
          (Dataset, IterableDataset) if isinstance(a_				,					a_			) else (IterableDataset, Dataset)
      )
    elif not isinstance(a_				,					a_			):
      raise ValueError(
          f"Unable to interleave a {dataset_type.__name__} (at position 0) with a {other_type.__name__} (at position {i}). Expected a list of Dataset objects or a list of IterableDataset objects."			)
  if dataset_type is Dataset:
    return _concatenate_map_style_datasets(a_				,					info=a_				,					split=a_				,					axis=a_			)
  else:
    return _concatenate_iterable_datasets(a_				,					info=a_				,					split=a_				,					axis=a_			)



