
class 					_lowerCamelCase			:





     """simple docstring"""







     def __init__(				self    ,    __SCREAMING_SNAKE_CASE = ""    ,    __SCREAMING_SNAKE_CASE = False	)	-> None:




           """simple docstring"""







           UpperCamelCase__     : dict[str, RadixNode]											=					{}

           # A node will be a leaf if the tree contains its word
           UpperCamelCase__     : Any											=					is_leaf

           UpperCamelCase__     : Dict											=					prefix






     def  __SCREAMING_SNAKE_CASE      (				self    ,    __SCREAMING_SNAKE_CASE	)	-> tuple[str, str, str]:




           """simple docstring"""







           UpperCamelCase__     : Any											=					0
           for q, w in zip(self.prefix    ,    __SCREAMING_SNAKE_CASE	):
                 if q != w:
                       break

                 x += 1

           return self.prefix[:x], self.prefix[x:], word[x:]






     def  __SCREAMING_SNAKE_CASE      (				self    ,    __SCREAMING_SNAKE_CASE	)	-> None:




           """simple docstring"""







           for word in words:
                 self.insert(__SCREAMING_SNAKE_CASE	)






     def  __SCREAMING_SNAKE_CASE      (				self    ,    __SCREAMING_SNAKE_CASE	)	-> None:




           """simple docstring"""







           if self.prefix == word:
                 UpperCamelCase__     : List[Any]											=					True

           # Case 2: The node has no edges that have a prefix to the word
           # Solution: We create an edge from the current node to a new one
           # containing the word
           elif word[0] not in self.nodes:
                 UpperCamelCase__     : List[str]											=					RadixNode(prefix=__SCREAMING_SNAKE_CASE    ,    is_leaf=__SCREAMING_SNAKE_CASE	)

           else:
                 UpperCamelCase__     : int											=					self.nodes[word[0]]
                 UpperCamelCase__					,UpperCamelCase__					,UpperCamelCase__     : Any											=					incoming_node.match(
                     __SCREAMING_SNAKE_CASE	)

                 # Case 3: The node prefix is equal to the matching
                 # Solution: We insert remaining word on the next node
                 if remaining_prefix == "":
                       self.nodes[matching_string[0]].insert(__SCREAMING_SNAKE_CASE	)

                 # Case 4: The word is greater equal to the matching
                 # Solution: Create a node in between both nodes, change
                 # prefixes and add the new node for the remaining word
                 else:
                       UpperCamelCase__     : List[str]											=					remaining_prefix

                       UpperCamelCase__     : Any											=					self.nodes[matching_string[0]]
                       UpperCamelCase__     : int											=					RadixNode(__SCREAMING_SNAKE_CASE    ,    __SCREAMING_SNAKE_CASE	)
                       UpperCamelCase__     : Tuple											=					aux_node

                       if remaining_word == "":
                             UpperCamelCase__     : int											=					True
                       else:
                             self.nodes[matching_string[0]].insert(__SCREAMING_SNAKE_CASE	)






     def  __SCREAMING_SNAKE_CASE      (				self    ,    __SCREAMING_SNAKE_CASE	)	-> bool:




           """simple docstring"""







           UpperCamelCase__     : int											=					self.nodes.get(word[0]    ,    __SCREAMING_SNAKE_CASE	)
           if not incoming_node:
                 return False
           else:
                 UpperCamelCase__					,UpperCamelCase__					,UpperCamelCase__     : Optional[Any]											=					incoming_node.match(
                     __SCREAMING_SNAKE_CASE	)
                 # If there is remaining prefix, the word can't be on the tree
                 if remaining_prefix != "":
                       return False
                 # This applies when the word and the prefix are equal
                 elif remaining_word == "":
                       return incoming_node.is_leaf
                 # We have word remaining so we check the next node
                 else:
                       return incoming_node.find(__SCREAMING_SNAKE_CASE	)






     def  __SCREAMING_SNAKE_CASE      (				self    ,    __SCREAMING_SNAKE_CASE	)	-> bool:




           """simple docstring"""







           UpperCamelCase__     : Optional[int]											=					self.nodes.get(word[0]    ,    __SCREAMING_SNAKE_CASE	)
           if not incoming_node:
                 return False
           else:
                 UpperCamelCase__					,UpperCamelCase__					,UpperCamelCase__     : List[Any]											=					incoming_node.match(
                     __SCREAMING_SNAKE_CASE	)
                 # If there is remaining prefix, the word can't be on the tree
                 if remaining_prefix != "":
                       return False
                 # We have word remaining so we check the next node
                 elif remaining_word != "":
                       return incoming_node.delete(__SCREAMING_SNAKE_CASE	)
                 else:
                       # If it is not a leaf, we don't have to delete
                       if not incoming_node.is_leaf:
                             return False
                       else:
                             # We delete the nodes if no edges go from it
                             if len(incoming_node.nodes	) == 0:
                                   del self.nodes[word[0]]
                                   # We merge the current node with its only child
                                   if len(self.nodes	) == 1 and not self.is_leaf:
                                         UpperCamelCase__     : Optional[Any]											=					list(self.nodes.values()	)[0]
                                         UpperCamelCase__     : Optional[int]											=					merging_node.is_leaf
                                         self.prefix += merging_node.prefix
                                         UpperCamelCase__     : List[str]											=					merging_node.nodes
                    # If there is more than 1 edge, we just mark it as non-leaf
                             elif len(incoming_node.nodes	) > 1:
                                   UpperCamelCase__     : List[str]											=					False
                             # If there is 1 edge, we merge it with its child
                             else:
                                   UpperCamelCase__     : int											=					list(incoming_node.nodes.values()	)[0]
                                   UpperCamelCase__     : str											=					merging_node.is_leaf
                                   incoming_node.prefix += merging_node.prefix
                                   UpperCamelCase__     : Any											=					merging_node.nodes

                             return True






     def  __SCREAMING_SNAKE_CASE      (				self    ,    __SCREAMING_SNAKE_CASE = 0	)	-> None:




           """simple docstring"""







           if self.prefix != "":
                 print('''-''' * height    ,    self.prefix    ,    '''  (leaf)''' if self.is_leaf else ''''''	)

           for value in self.nodes.values():
                 value.print_tree(height + 1	)


def 				SCREAMING_SNAKE_CASE_   (      ):
      UpperCamelCase__     : int											=					'''banana bananas bandana band apple all beast'''.split()
      UpperCamelCase__     : Any											=					RadixNode()
      root.insert_many(UpperCamelCase__		)

      assert all(root.find(UpperCamelCase__		) for word in words		)
      assert not root.find('''bandanas'''		)
      assert not root.find('''apps'''		)
      root.delete('''all'''		)
      assert not root.find('''all'''		)
      root.delete('''banana'''		)
      assert not root.find('''banana'''		)
      assert root.find('''bananas'''		)

      return True


def 				SCREAMING_SNAKE_CASE_   (      ):
      assert test_trie()


def 				SCREAMING_SNAKE_CASE_   (      ):
      UpperCamelCase__     : Any											=					RadixNode()
      UpperCamelCase__     : Any											=					'''banana bananas bandanas bandana band apple all beast'''.split()
      root.insert_many(UpperCamelCase__		)

      print('''Words:'''			,		UpperCamelCase__		)
      print('''Tree:'''		)
      root.print_tree()


if __name__ == "__main__":
    main()




import functools
import operator

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


lowerCamelCase  =logging.get_logger(__name__)

lowerCamelCase  ={
    "facebook/wav2vec2-base-960h": "https://huggingface.co/facebook/wav2vec2-base-960h/resolve/main/config.json",
    # See all Wav2Vec2 models at https://huggingface.co/models?filter=wav2vec2
}




class 					_lowerCamelCase			(   UpperCamelCase_			):





     """simple docstring"""







     SCREAMING_SNAKE_CASE_		 =	'''wav2vec2'''






     def __init__(				self    ,    __SCREAMING_SNAKE_CASE=3_2    ,    __SCREAMING_SNAKE_CASE=7_6_8    ,    __SCREAMING_SNAKE_CASE=1_2    ,    __SCREAMING_SNAKE_CASE=1_2    ,    __SCREAMING_SNAKE_CASE=3_0_7_2    ,    __SCREAMING_SNAKE_CASE="gelu"    ,    __SCREAMING_SNAKE_CASE=0.1    ,    __SCREAMING_SNAKE_CASE=0.1    ,    __SCREAMING_SNAKE_CASE=0.1    ,    __SCREAMING_SNAKE_CASE=0.0    ,    __SCREAMING_SNAKE_CASE=0.0    ,    __SCREAMING_SNAKE_CASE=0.1    ,    __SCREAMING_SNAKE_CASE=0.1    ,    __SCREAMING_SNAKE_CASE=0.02    ,    __SCREAMING_SNAKE_CASE=1e-5    ,    __SCREAMING_SNAKE_CASE="group"    ,    __SCREAMING_SNAKE_CASE="gelu"    ,    __SCREAMING_SNAKE_CASE=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2, 5_1_2)    ,    __SCREAMING_SNAKE_CASE=(5, 2, 2, 2, 2, 2, 2)    ,    __SCREAMING_SNAKE_CASE=(1_0, 3, 3, 3, 3, 2, 2)    ,    __SCREAMING_SNAKE_CASE=False    ,    __SCREAMING_SNAKE_CASE=1_2_8    ,    __SCREAMING_SNAKE_CASE=1_6    ,    __SCREAMING_SNAKE_CASE=False    ,    __SCREAMING_SNAKE_CASE=True    ,    __SCREAMING_SNAKE_CASE=0.05    ,    __SCREAMING_SNAKE_CASE=1_0    ,    __SCREAMING_SNAKE_CASE=2    ,    __SCREAMING_SNAKE_CASE=0.0    ,    __SCREAMING_SNAKE_CASE=1_0    ,    __SCREAMING_SNAKE_CASE=0    ,    __SCREAMING_SNAKE_CASE=3_2_0    ,    __SCREAMING_SNAKE_CASE=2    ,    __SCREAMING_SNAKE_CASE=0.1    ,    __SCREAMING_SNAKE_CASE=1_0_0    ,    __SCREAMING_SNAKE_CASE=2_5_6    ,    __SCREAMING_SNAKE_CASE=2_5_6    ,    __SCREAMING_SNAKE_CASE=0.1    ,    __SCREAMING_SNAKE_CASE="sum"    ,    __SCREAMING_SNAKE_CASE=False    ,    __SCREAMING_SNAKE_CASE=False    ,    __SCREAMING_SNAKE_CASE=2_5_6    ,    __SCREAMING_SNAKE_CASE=(5_1_2, 5_1_2, 5_1_2, 5_1_2, 1_5_0_0)    ,    __SCREAMING_SNAKE_CASE=(5, 3, 3, 1, 1)    ,    __SCREAMING_SNAKE_CASE=(1, 2, 3, 1, 1)    ,    __SCREAMING_SNAKE_CASE=5_1_2    ,    __SCREAMING_SNAKE_CASE=0    ,    __SCREAMING_SNAKE_CASE=1    ,    __SCREAMING_SNAKE_CASE=2    ,    __SCREAMING_SNAKE_CASE=False    ,    __SCREAMING_SNAKE_CASE=3    ,    __SCREAMING_SNAKE_CASE=2    ,    __SCREAMING_SNAKE_CASE=3    ,    __SCREAMING_SNAKE_CASE=None    ,    __SCREAMING_SNAKE_CASE=None    ,    **__SCREAMING_SNAKE_CASE    ,    )	-> str:




           """simple docstring"""







           super().__init__(**__SCREAMING_SNAKE_CASE    ,    pad_token_id=__SCREAMING_SNAKE_CASE    ,    bos_token_id=__SCREAMING_SNAKE_CASE    ,    eos_token_id=__SCREAMING_SNAKE_CASE	)
           UpperCamelCase__     : str											=					hidden_size
           UpperCamelCase__     : List[Any]											=					feat_extract_norm
           UpperCamelCase__     : Union[str, Any]											=					feat_extract_activation
           UpperCamelCase__     : Union[str, Any]											=					list(__SCREAMING_SNAKE_CASE	)
           UpperCamelCase__     : Dict											=					list(__SCREAMING_SNAKE_CASE	)
           UpperCamelCase__     : Dict											=					list(__SCREAMING_SNAKE_CASE	)
           UpperCamelCase__     : Tuple											=					conv_bias
           UpperCamelCase__     : Optional[Any]											=					num_conv_pos_embeddings
           UpperCamelCase__     : Tuple											=					num_conv_pos_embedding_groups
           UpperCamelCase__     : Tuple											=					len(self.conv_dim	)
           UpperCamelCase__     : Optional[Any]											=					num_hidden_layers
           UpperCamelCase__     : Union[str, Any]											=					intermediate_size
           UpperCamelCase__     : Union[str, Any]											=					hidden_act
           UpperCamelCase__     : List[Any]											=					num_attention_heads
           UpperCamelCase__     : Optional[int]											=					hidden_dropout
           UpperCamelCase__     : Tuple											=					attention_dropout
           UpperCamelCase__     : List[Any]											=					activation_dropout
           UpperCamelCase__     : Optional[int]											=					feat_proj_dropout
           UpperCamelCase__     : int											=					final_dropout
           UpperCamelCase__     : str											=					layerdrop
           UpperCamelCase__     : Dict											=					layer_norm_eps
           UpperCamelCase__     : str											=					initializer_range
           UpperCamelCase__     : List[Any]											=					vocab_size
           UpperCamelCase__     : Dict											=					do_stable_layer_norm
           UpperCamelCase__     : Dict											=					use_weighted_layer_sum

           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__     : Tuple											=					apply_spec_augment
           UpperCamelCase__     : str											=					mask_time_prob
           UpperCamelCase__     : Tuple											=					mask_time_length
           UpperCamelCase__     : Optional[Any]											=					mask_time_min_masks
           UpperCamelCase__     : str											=					mask_feature_prob
           UpperCamelCase__     : List[str]											=					mask_feature_length
           UpperCamelCase__     : Optional[Any]											=					mask_feature_min_masks

           # parameters for pretraining with codevector quantized representations
           UpperCamelCase__     : Dict											=					num_codevectors_per_group
           UpperCamelCase__     : Optional[int]											=					num_codevector_groups
           UpperCamelCase__     : Dict											=					contrastive_logits_temperature
           UpperCamelCase__     : List[Any]											=					feat_quantizer_dropout
           UpperCamelCase__     : List[Any]											=					num_negatives
           UpperCamelCase__     : Tuple											=					codevector_dim
           UpperCamelCase__     : List[str]											=					proj_codevector_dim
           UpperCamelCase__     : Tuple											=					diversity_loss_weight

           # ctc loss
           UpperCamelCase__     : List[str]											=					ctc_loss_reduction
           UpperCamelCase__     : Optional[Any]											=					ctc_zero_infinity

           # adapter
           UpperCamelCase__     : List[Any]											=					add_adapter
           UpperCamelCase__     : Any											=					adapter_kernel_size
           UpperCamelCase__     : Tuple											=					adapter_stride
           UpperCamelCase__     : Tuple											=					num_adapter_layers
           UpperCamelCase__     : Optional[Any]											=					output_hidden_size or hidden_size
           UpperCamelCase__     : Union[str, Any]											=					adapter_attn_dim

           # SequenceClassification-specific parameter. Feel free to ignore for other classes.
           UpperCamelCase__     : List[str]											=					classifier_proj_size

           # XVector-specific parameters. Feel free to ignore for other classes.
           UpperCamelCase__     : Union[str, Any]											=					list(__SCREAMING_SNAKE_CASE	)
           UpperCamelCase__     : List[str]											=					list(__SCREAMING_SNAKE_CASE	)
           UpperCamelCase__     : Optional[Any]											=					list(__SCREAMING_SNAKE_CASE	)
           UpperCamelCase__     : int											=					xvector_output_dim






     @property
     def  __SCREAMING_SNAKE_CASE      (				self	)	-> Optional[Any]:




           """simple docstring"""







           return functools.reduce(operator.mul    ,    self.conv_stride    ,    1	)


