
'''simple docstring'''





import textwrap

import pyarrow as pa
import pytest

from datasets import Features, Value
from datasets.packaged_modules.json.json import Json





@pytest.fixture
def 							snake_case				(		UpperCAmelCase						)->      Tuple:







      """simple docstring"""
      __A													=      tmp_path / 'file.jsonl'
      __A													=      textwrap.dedent(
          '\\n        {"col_1": -1}\n        {"col_1": 1, "col_2": 2}\n        {"col_1": 10, "col_2": 20}\n        '						)
      with open(UpperCAmelCase   ,	'w'						) as f:
            f.write(UpperCAmelCase						)
      return str(UpperCAmelCase						)





@pytest.fixture
def 							snake_case				(		UpperCAmelCase						)->      Any:







      """simple docstring"""
      __A													=      tmp_path / 'file_utf16_encoded.jsonl'
      __A													=      textwrap.dedent(
          '\\n        {"col_1": -1}\n        {"col_1": 1, "col_2": 2}\n        {"col_1": 10, "col_2": 20}\n        '						)
      with open(UpperCAmelCase   ,	'w'   ,	encoding='utf-16'						) as f:
            f.write(UpperCAmelCase						)
      return str(UpperCAmelCase						)





@pytest.fixture
def 							snake_case				(		UpperCAmelCase						)->      Optional[int]:







      """simple docstring"""
      __A													=      tmp_path / 'file_with_list_of_dicts.json'
      __A													=      textwrap.dedent(
          '\\n        [\n            {"col_1": -1},\n            {"col_1": 1, "col_2": 2},\n            {"col_1": 10, "col_2": 20}\n        ]\n        '						)
      with open(UpperCAmelCase   ,	'w'						) as f:
            f.write(UpperCAmelCase						)
      return str(UpperCAmelCase						)





@pytest.fixture
def 							snake_case				(		UpperCAmelCase						)->      Optional[Any]:







      """simple docstring"""
      __A													=      tmp_path / 'file_with_list_of_dicts_field.json'
      __A													=      textwrap.dedent(
          '\\n        {\n            "field1": 1,\n            "field2": "aabb",\n            "field3": [\n                {"col_1": -1},\n                {"col_1": 1, "col_2": 2},\n                {"col_1": 10, "col_2": 20}\n            ]\n        }\n        '						)
      with open(UpperCAmelCase   ,	'w'						) as f:
            f.write(UpperCAmelCase						)
      return str(UpperCAmelCase						)





@pytest.mark.parametrize(
    'file_fixture, config_kwargs'   ,	[
        ('jsonl_file', {}),
        ('jsonl_file_utf16_encoded', {'encoding': 'utf-16'}),
        ('json_file_with_list_of_dicts', {}),
        ('json_file_with_list_of_dicts_field', {'field': 'field3'}),
    ]   ,	)
def 							snake_case				(		UpperCAmelCase   ,	UpperCAmelCase   ,	UpperCAmelCase						)->      List[str]:







      """simple docstring"""
      __A													=      Json(**UpperCAmelCase						)
      __A													=      json._generate_tables([[request.getfixturevalue(UpperCAmelCase						)]]						)
      __A													=      pa.concat_tables([table for _, table in generator]						)
      assert pa_table.to_pydict() == {"col_1": [-1, 1, 1_0], "col_2": [None, 2, 2_0]}





@pytest.mark.parametrize(
    'file_fixture, config_kwargs'   ,	[
        (
            'jsonl_file',
            {'features': Features({'col_1': Value('int64'						), 'col_2': Value('int64'						), 'missing_col': Value('string'						)}						)},
        ),
        (
            'json_file_with_list_of_dicts',
            {'features': Features({'col_1': Value('int64'						), 'col_2': Value('int64'						), 'missing_col': Value('string'						)}						)},
        ),
        (
            'json_file_with_list_of_dicts_field',
            {
                'field': 'field3',
                'features': Features(
                    {'col_1': Value('int64'						), 'col_2': Value('int64'						), 'missing_col': Value('string'						)}						),
            },
        ),
    ]   ,	)
def 							snake_case				(		UpperCAmelCase   ,	UpperCAmelCase   ,	UpperCAmelCase						)->      Dict:







      """simple docstring"""
      __A													=      Json(**UpperCAmelCase						)
      __A													=      json._generate_tables([[request.getfixturevalue(UpperCAmelCase						)]]						)
      __A													=      pa.concat_tables([table for _, table in generator]						)
      assert pa_table.to_pydict() == {"col_1": [-1, 1, 1_0], "col_2": [None, 2, 2_0], "missing_col": [None, None, None]}











'''simple docstring'''




import functools
import operator

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


a  :     Union[str, Any]       =       logging.get_logger(__name__)

a  :     int       =       {
    """facebook/hubert-base-ls960""": """https://huggingface.co/facebook/hubert-base-ls960/resolve/main/config.json""",
    # See all Hubert models at https://huggingface.co/models?filter=hubert
}

class      UpperCamelCase_					(				__magic_name__     ):
	lowercase		=					'hubert'





	def __init__(    self						,						A=32						,						A=768						,						A=12						,						A=12						,						A=3072						,						A="gelu"						,						A=0.1						,						A=0.1						,						A=0.1						,						A=True						,						A=0.0						,						A=0.1						,						A=0.1						,						A=0.0_2						,						A=1e-5						,						A="group"						,						A="gelu"						,						A=(512, 512, 512, 512, 512, 512, 512)						,						A=(5, 2, 2, 2, 2, 2, 2)						,						A=(10, 3, 3, 3, 3, 2, 2)						,						A=False						,						A=128						,						A=16						,						A=False						,						A=True						,						A=0.0_5						,						A=10						,						A=2						,						A=0.0						,						A=10						,						A=0						,						A="sum"						,						A=False						,						A=False						,						A=256						,						A=0						,						A=1						,						A=2						,						**A						,						)     ->     List[str]:
								super().__init__(**A						,						pad_token_id=A						,						bos_token_id=A						,						eos_token_id=A       )
								UpperCAmelCase	:						List[Any]					=						hidden_size
								UpperCAmelCase	:						List[Any]					=						feat_extract_norm
								UpperCAmelCase	:						Optional[Any]					=						feat_extract_activation
								UpperCAmelCase	:						Optional[int]					=						list(A       )
								UpperCAmelCase	:						int					=						list(A       )
								UpperCAmelCase	:						Any					=						list(A       )
								UpperCAmelCase	:						Any					=						conv_bias
								UpperCAmelCase	:						Dict					=						num_conv_pos_embeddings
								UpperCAmelCase	:						Tuple					=						num_conv_pos_embedding_groups
								UpperCAmelCase	:						str					=						len(self.conv_dim       )
								UpperCAmelCase	:						Optional[Any]					=						num_hidden_layers
								UpperCAmelCase	:						int					=						intermediate_size
								UpperCAmelCase	:						Any					=						hidden_act
								UpperCAmelCase	:						Tuple					=						num_attention_heads
								UpperCAmelCase	:						int					=						hidden_dropout
								UpperCAmelCase	:						Any					=						attention_dropout
								UpperCAmelCase	:						Any					=						activation_dropout
								UpperCAmelCase	:						str					=						feat_proj_layer_norm
								UpperCAmelCase	:						int					=						feat_proj_dropout
								UpperCAmelCase	:						List[Any]					=						final_dropout
								UpperCAmelCase	:						int					=						layerdrop
								UpperCAmelCase	:						Dict					=						layer_norm_eps
								UpperCAmelCase	:						Union[str, Any]					=						initializer_range
								UpperCAmelCase	:						Any					=						vocab_size
								UpperCAmelCase	:						Optional[int]					=						do_stable_layer_norm
								UpperCAmelCase	:						Optional[int]					=						use_weighted_layer_sum
								UpperCAmelCase	:						Dict					=						classifier_proj_size

								if (
								    (len(self.conv_stride       ) != self.num_feat_extract_layers)
								    or (len(self.conv_kernel       ) != self.num_feat_extract_layers)
								    or (len(self.conv_dim       ) != self.num_feat_extract_layers)
								):
															raise ValueError(
															    """Configuration for convolutional layers is incorrect. It is required that `len(config.conv_dim)` =="""
															    """ `len(config.conv_stride)` == `len(config.conv_kernel)`, but is `len(config.conv_dim) ="""
															    f''' {len(self.conv_dim       )}`, `len(config.conv_stride) = {len(self.conv_stride       )}`,'''
															    f''' `len(config.conv_kernel) = {len(self.conv_kernel       )}`.'''       )

								# fine-tuning config parameters for SpecAugment: https://arxiv.org/abs/1904.08779
								UpperCAmelCase	:						Union[str, Any]					=						apply_spec_augment
								UpperCAmelCase	:						Tuple					=						mask_time_prob
								UpperCAmelCase	:						Optional[Any]					=						mask_time_length
								UpperCAmelCase	:						List[Any]					=						mask_time_min_masks
								UpperCAmelCase	:						Any					=						mask_feature_prob
								UpperCAmelCase	:						Any					=						mask_feature_length
								UpperCAmelCase	:						Tuple					=						mask_feature_min_masks

								# ctc loss
								UpperCAmelCase	:						int					=						ctc_loss_reduction
								UpperCAmelCase	:						Any					=						ctc_zero_infinity






	@property
	def 					_lowercase(    self       )     ->     Union[str, Any]:
								return functools.reduce(operator.mul						,						self.conv_stride						,						1       )

