


"""simple docstring"""
# Copyright 2023 The HuggingFace Inc. team. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import copy
import importlib.metadata
import json
import os
from dataclasses import dataclass
from typing import Any, Dict, Union

from packaging import version

from ..utils import is_torch_available, logging


if is_torch_available():
				import torch


__SCREAMING_SNAKE_CASE							:    Tuple		=    logging.get_logger(__name__)





@dataclass
class      __A     :





							'''simple docstring'''

							def __init__(				self							:      Optional[int]		,       UpperCAmelCase_							:      Optional[Any]=False		,       UpperCAmelCase_							:      Tuple=False		,       UpperCAmelCase_							:      List[str]=6.0		,       UpperCAmelCase_							:      List[str]=None		,       UpperCAmelCase_							:      int=False		,       UpperCAmelCase_							:      List[str]=False		,       UpperCAmelCase_							:      Union[str, Any]=None		,       UpperCAmelCase_							:      Any="fp4"		,       UpperCAmelCase_							:      Union[str, Any]=False		,       **UpperCAmelCase_							:      Union[str, Any]		,       )					->List[str]:



														"""simple docstring"""



														snake_case_           =		load_in_abit
														snake_case_           =		load_in_abit
														snake_case_           =		llm_inta_threshold
														snake_case_           =		llm_inta_skip_modules
														snake_case_           =		llm_inta_enable_fpaa_cpu_offload
														snake_case_           =		llm_inta_has_fpaa_weight
														snake_case_           =		bnb_abit_quant_type
														snake_case_           =		bnb_abit_use_double_quant

														if bnb_abit_compute_dtype is None:
																					snake_case_           =		torch.floataa
														elif isinstance(UpperCAmelCase_		,       UpperCAmelCase_       ):
																					snake_case_           =		getattr(UpperCAmelCase_		,       UpperCAmelCase_       )
														elif isinstance(UpperCAmelCase_		,       torch.dtype       ):
																					snake_case_           =		bnb_abit_compute_dtype
														else:
																					raise ValueError("""bnb_4bit_compute_dtype must be a string or a torch.dtype"""       )

														self.post_init()



							def 		lowerCAmelCase       (				self							:      Tuple       )					->List[str]:



														"""simple docstring"""



														if not isinstance(self.llm_inta_threshold		,       UpperCAmelCase_       ):
																					raise ValueError("""llm_int8_threshold must be a float"""       )

														if self.llm_inta_skip_modules is not None and not isinstance(self.llm_inta_skip_modules		,       UpperCAmelCase_       ):
																					raise ValueError("""llm_int8_skip_modules must be a list of strings"""       )
														if not isinstance(self.llm_inta_enable_fpaa_cpu_offload		,       UpperCAmelCase_       ):
																					raise ValueError("""llm_int8_enable_fp32_cpu_offload must be a boolean"""       )

														if not isinstance(self.llm_inta_has_fpaa_weight		,       UpperCAmelCase_       ):
																					raise ValueError("""llm_int8_has_fp16_weight must be a boolean"""       )

														if self.bnb_abit_compute_dtype is not None and not isinstance(self.bnb_abit_compute_dtype		,       torch.dtype       ):
																					raise ValueError("""bnb_4bit_compute_dtype must be torch.dtype"""       )

														if not isinstance(self.bnb_abit_quant_type		,       UpperCAmelCase_       ):
																					raise ValueError("""bnb_4bit_quant_type must be a string"""       )

														if not isinstance(self.bnb_abit_use_double_quant		,       UpperCAmelCase_       ):
																					raise ValueError("""bnb_4bit_use_double_quant must be a boolean"""       )

														if self.load_in_abit and not version.parse(importlib.metadata.version("""bitsandbytes"""       )       ) >= version.parse(
														    """0.39.0"""       ):
																					raise ValueError(
																					    """4 bit quantization requires bitsandbytes>=0.39.0 - please upgrade your bitsandbytes version"""       )



							def 		lowerCAmelCase       (				self							:      int       )					->Tuple:



														"""simple docstring"""



														return self.load_in_abit or self.load_in_abit



							def 		lowerCAmelCase       (				self							:      Union[str, Any]       )					->Any:



														"""simple docstring"""



														if self.load_in_abit:
																					return "llm_int8"
														elif self.load_in_abit and self.bnb_abit_quant_type == "fp4":
																					return "fp4"
														elif self.load_in_abit and self.bnb_abit_quant_type == "nf4":
																					return "nf4"
														else:
																					return None



							@classmethod
							def 		lowerCAmelCase       (				cls							:      Any		,       UpperCAmelCase_							:      Tuple		,       UpperCAmelCase_							:      Optional[int]		,       **UpperCAmelCase_							:      Union[str, Any]       )					->Union[str, Any]:



														"""simple docstring"""



														snake_case_           =		cls(**UpperCAmelCase_       )

														snake_case_           =		[]
														for key, value in kwargs.items():
																					if hasattr(UpperCAmelCase_		,       UpperCAmelCase_       ):
																												setattr(UpperCAmelCase_		,       UpperCAmelCase_		,       UpperCAmelCase_       )
																												to_remove.append(UpperCAmelCase_       )
														for key in to_remove:
																					kwargs.pop(UpperCAmelCase_		,       UpperCAmelCase_       )

														if return_unused_kwargs:
																					return config, kwargs
														else:
																					return config



							def 		lowerCAmelCase       (				self							:      Union[str, Any]		,       UpperCAmelCase_							:      Union[str, os.PathLike]       )					->Any:



														"""simple docstring"""



														with open(UpperCAmelCase_		,       """w"""		,       encoding="""utf-8"""       ) as writer:
																					snake_case_           =		self.to_dict()
																					snake_case_           =		json.dumps(UpperCAmelCase_		,       indent=2		,       sort_keys=UpperCAmelCase_       ) + """\n"""

																					writer.write(UpperCAmelCase_       )



							def 		lowerCAmelCase       (				self							:      Any       )					->Dict[str, Any]:



														"""simple docstring"""



														snake_case_           =		copy.deepcopy(self.__dict__       )
														snake_case_           =		str(output["""bnb_4bit_compute_dtype"""]       ).split("""."""       )[1]

														return output



							def __repr__(				self							:      Optional[Any]       )					->int:



														"""simple docstring"""



														return F"""{self.__class__.__name__} {self.to_json_string()}"""



							def 		lowerCAmelCase       (				self							:      List[str]		,       UpperCAmelCase_							:      bool = True       )					->str:



														"""simple docstring"""



														if use_diff is True:
																					snake_case_           =		self.to_diff_dict()
														else:
																					snake_case_           =		self.to_dict()
														return json.dumps(UpperCAmelCase_		,       indent=2		,       sort_keys=UpperCAmelCase_       ) + "\n"



							def 		lowerCAmelCase       (				self							:      Any       )					->Dict[str, Any]:



														"""simple docstring"""



														snake_case_           =		self.to_dict()

														# get the default config dict
														snake_case_           =		BitsAndBytesConfig().to_dict()

														snake_case_           =		{}

														# only serialize values that differ from the default config
														for key, value in config_dict.items():
																					if value != default_config_dict[key]:
																												snake_case_           =		value

														return serializable_config_dict







"""simple docstring"""
from ....configuration_utils import PretrainedConfig
from ....utils import logging


__SCREAMING_SNAKE_CASE							:    str		=    logging.get_logger(__name__)

__SCREAMING_SNAKE_CASE							:    str		=    {
    'speechbrain/m-ctc-t-large': 'https://huggingface.co/speechbrain/m-ctc-t-large/resolve/main/config.json',
    # See all M-CTC-T models at https://huggingface.co/models?filter=mctct
}





class      __A     (snake_case__):





							'''simple docstring'''

							__lowercase:		Any							      =    """mctct"""



							def __init__(				self							:      Dict		,       UpperCAmelCase_							:      List[Any]=8_065		,       UpperCAmelCase_							:      Tuple=1_536		,       UpperCAmelCase_							:      Optional[Any]=36		,       UpperCAmelCase_							:      int=6_144		,       UpperCAmelCase_							:      Dict=4		,       UpperCAmelCase_							:      Any=384		,       UpperCAmelCase_							:      List[str]=920		,       UpperCAmelCase_							:      Any=1E-5		,       UpperCAmelCase_							:      Any=0.3		,       UpperCAmelCase_							:      Tuple="relu"		,       UpperCAmelCase_							:      Union[str, Any]=0.02		,       UpperCAmelCase_							:      Dict=0.3		,       UpperCAmelCase_							:      str=0.3		,       UpperCAmelCase_							:      Any=1		,       UpperCAmelCase_							:      Any=0		,       UpperCAmelCase_							:      int=2		,       UpperCAmelCase_							:      str=1		,       UpperCAmelCase_							:      Tuple=0.3		,       UpperCAmelCase_							:      Optional[Any]=1		,       UpperCAmelCase_							:      Optional[Any]=(7,)		,       UpperCAmelCase_							:      Optional[Any]=(3,)		,       UpperCAmelCase_							:      List[str]=80		,       UpperCAmelCase_							:      Tuple=1		,       UpperCAmelCase_							:      List[Any]=None		,       UpperCAmelCase_							:      List[str]="sum"		,       UpperCAmelCase_							:      Union[str, Any]=False		,       **UpperCAmelCase_							:      Any		,       )					->Dict:



														"""simple docstring"""



														super().__init__(**UpperCAmelCase_		,       pad_token_id=UpperCAmelCase_		,       bos_token_id=UpperCAmelCase_		,       eos_token_id=UpperCAmelCase_       )
														snake_case_           =		vocab_size
														snake_case_           =		hidden_size
														snake_case_           =		num_hidden_layers
														snake_case_           =		intermediate_size
														snake_case_           =		num_attention_heads
														snake_case_           =		attention_head_dim
														snake_case_           =		max_position_embeddings
														snake_case_           =		layer_norm_eps
														snake_case_           =		layerdrop
														snake_case_           =		hidden_act
														snake_case_           =		initializer_range
														snake_case_           =		hidden_dropout_prob
														snake_case_           =		attention_probs_dropout_prob
														snake_case_           =		pad_token_id
														snake_case_           =		bos_token_id
														snake_case_           =		eos_token_id
														snake_case_           =		conv_glu_dim
														snake_case_           =		conv_dropout
														snake_case_           =		num_conv_layers
														snake_case_           =		input_feat_per_channel
														snake_case_           =		input_channels
														snake_case_           =		conv_channels
														snake_case_           =		ctc_loss_reduction
														snake_case_           =		ctc_zero_infinity

														# prevents config testing fail with exporting to json
														snake_case_           =		list(UpperCAmelCase_       )
														snake_case_           =		list(UpperCAmelCase_       )

														if len(self.conv_kernel       ) != self.num_conv_layers:
																					raise ValueError(
																					    """Configuration for convolutional module is incorrect. """
																					    """It is required that `len(config.conv_kernel)` == `config.num_conv_layers` """
																					    F"""but is `len(config.conv_kernel) = {len(self.conv_kernel       )}`, """
																					    F"""`config.num_conv_layers = {self.num_conv_layers}`."""       )



