



"""simple docstring"""

import copy
import fnmatch
import json
import os
import pickle as pkl
import shutil
import sys
import tarfile
import tempfile
from collections import OrderedDict
from contextlib import contextmanager
from functools import partial
from hashlib import shaaaa
from io import BytesIO
from pathlib import Path
from urllib.parse import urlparse
from zipfile import ZipFile, is_zipfile

import cva
import numpy as np
import requests
import wget
from filelock import FileLock
from PIL import Image
from tqdm.auto import tqdm
from yaml import Loader, dump, load


try:
	import torch

	lowercase__			   =  True
except ImportError:
	lowercase__			   =  False


try:
	from torch.hub import _get_torch_home

	lowercase__			   =  _get_torch_home()
except ImportError:
	lowercase__			   =  os.path.expanduser(
	    os.getenv("TORCH_HOME", os.path.join(os.getenv("XDG_CACHE_HOME", "~/.cache"), "torch"))
	)

lowercase__			   =  os.path.join(torch_cache_home, "transformers")

lowercase__			   =  "https://cdn.huggingface.co"
lowercase__			   =  "https://s3.amazonaws.com/models.huggingface.co/bert"
lowercase__			   =  "/".join(str(Path(__file__).resolve()).split("/")[:-1])
lowercase__			   =  os.path.join(PATH, "config.yaml")
lowercase__			   =  os.path.join(PATH, "attributes.txt")
lowercase__			   =  os.path.join(PATH, "objects.txt")
lowercase__			   =  os.getenv("PYTORCH_PRETRAINED_BERT_CACHE", default_cache_path)
lowercase__			   =  os.getenv("PYTORCH_TRANSFORMERS_CACHE", PYTORCH_PRETRAINED_BERT_CACHE)
lowercase__			   =  os.getenv("TRANSFORMERS_CACHE", PYTORCH_TRANSFORMERS_CACHE)
lowercase__			   =  "pytorch_model.bin"
lowercase__			   =  "config.yaml"





def       __magic_name__    (   _lowerCamelCase				: Dict=OBJECTS  ,       _lowerCamelCase				: Tuple=ATTRIBUTES					):
							__a		:		List[Any]									=       []
							with open(_lowerCamelCase					) as f:
														for object in f.readlines():
																					vg_classes.append(object.split(""","""					)[0].lower().strip()					)

							__a		:		Tuple									=       []
							with open(_lowerCamelCase					) as f:
														for object in f.readlines():
																					vg_attrs.append(object.split(""","""					)[0].lower().strip()					)
							return vg_classes, vg_attrs





def       __magic_name__    (   _lowerCamelCase				: Optional[Any]					):
							__a		:		Union[str, Any]									=       OrderedDict()
							with open(_lowerCamelCase  ,       """rb"""					) as f:
														__a		:		Union[str, Any]									=       pkl.load(_lowerCamelCase					)["""model"""]
							for k in copy.deepcopy(list(ckp.keys()					)					):
														__a		:		Dict									=       ckp.pop(_lowerCamelCase					)
														if isinstance(_lowerCamelCase  ,       np.ndarray					):
																					__a		:		List[str]									=       torch.tensor(_lowerCamelCase					)
														else:
																					assert isinstance(_lowerCamelCase  ,       torch.tensor					), type(_lowerCamelCase					)
														__a		:		str									=       v
							return r




class SCREAMING_SNAKE_CASE__					:
						_lowerCAmelCase							=					{}



						def __init__(self						,     _lowercase						,     _lowercase = "root"						,     _lowercase=0							):





													'''simple docstring'''

													__a		:		Dict									=       name
													__a		:		Union[str, Any]									=       level
													__a		:		List[str]									=       {}
													for k, v in dictionary.items():
																				if v is None:
																											raise ValueError()
																				__a		:		Dict									=       copy.deepcopy(_lowercase							)
																				__a		:		Tuple									=       copy.deepcopy(_lowercase							)
																				if isinstance(_lowercase						,     _lowercase							):
																											__a		:		int									=       Config(_lowercase						,     name=_lowercase						,     level=level + 1							)
																				__a		:		Dict									=       v
																				setattr(self						,     _lowercase						,     _lowercase							)

													__a		:		str									=       d



						def __repr__(self							):





													'''simple docstring'''

													return str(list((self._pointer.keys())							)							)



						def __setattr__(self						,     _lowercase						,     _lowercase							):





													'''simple docstring'''

													__a		:		Optional[Any]									=       val
													__a		:		Union[str, Any]									=       val
													__a		:		List[Any]									=       key.split("""."""							)
													__a		:		List[str]									=       len(_lowercase							) - 1
													__a		:		int									=       self._pointer
													if len(_lowercase							) > 1:
																				for i, l in enumerate(_lowercase							):
																											if hasattr(self						,     _lowercase							) and isinstance(getattr(self						,     _lowercase							)						,     _lowercase							):
																																		setattr(getattr(self						,     _lowercase							)						,     """.""".join(levels[i:]							)						,     _lowercase							)
																											if l == last_level:
																																		__a		:		Optional[Any]									=       val
																											else:
																																		__a		:		List[str]									=       pointer[l]



						def     lowerCAmelCase__(self							):





													'''simple docstring'''

													return self._pointer



						def     lowerCAmelCase__(self						,     _lowercase						,     _lowercase							):





													'''simple docstring'''

													with open(F'''{file_name}'''						,     """w"""							) as stream:
																				dump(_lowercase						,     _lowercase							)



						def     lowerCAmelCase__(self						,     _lowercase						,     _lowercase							):





													'''simple docstring'''

													with open(F'''{file_name}'''						,     """w"""							) as stream:
																				json.dump(_lowercase						,     _lowercase							)



						@staticmethod
						def     lowerCAmelCase__(_lowercase							):





													'''simple docstring'''

													with open(_lowercase							) as stream:
																				__a		:		Optional[Any]									=       load(_lowercase						,     Loader=_lowercase							)
													return data



						def __str__(self							):





													'''simple docstring'''

													__a		:		Tuple									=       """    """
													if self._name != "root":
																				__a		:		int									=       F'''{t * (self._level-1)}{self._name}:\n'''
													else:
																				__a		:		Optional[Any]									=       """"""
													__a		:		str									=       self._level
													for i, (k, v) in enumerate(self._pointer.items()							):
																				if isinstance(_lowercase						,     _lowercase							):
																											r += F'''{t * (self._level)}{v}\n'''
																											self._level += 1
																				else:
																											r += F'''{t * (self._level)}{k}: {v} ({type(_lowercase							).__name__})\n'''
																				__a		:		Tuple									=       level
													return r[:-1]



						@classmethod
						def     lowerCAmelCase__(cls						,     _lowercase						,     **_lowercase							):





													'''simple docstring'''

													__a							,     __a		:		Any									=       cls.get_config_dict(_lowercase						,     **_lowercase							)
													return cls(_lowercase							)





						@classmethod
						def     lowerCAmelCase__(cls						,     _lowercase						,     **_lowercase							):





													'''simple docstring'''

													__a		:		Union[str, Any]									=       kwargs.pop("""cache_dir"""						,     _lowercase							)
													__a		:		Any									=       kwargs.pop("""force_download"""						,     _lowercase							)
													__a		:		str									=       kwargs.pop("""resume_download"""						,     _lowercase							)
													__a		:		int									=       kwargs.pop("""proxies"""						,     _lowercase							)
													__a		:		str									=       kwargs.pop("""local_files_only"""						,     _lowercase							)

													if os.path.isdir(_lowercase							):
																				__a		:		str									=       os.path.join(_lowercase						,     _lowercase							)
													elif os.path.isfile(_lowercase							) or is_remote_url(_lowercase							):
																				__a		:		Dict									=       pretrained_model_name_or_path
													else:
																				__a		:		List[str]									=       hf_bucket_url(_lowercase						,     filename=_lowercase						,     use_cdn=_lowercase							)

													try:
																				# Load from URL or cache if already cached
																				__a		:		Optional[Any]									=       cached_path(
																				    _lowercase						,     cache_dir=_lowercase						,     force_download=_lowercase						,     proxies=_lowercase						,     resume_download=_lowercase						,     local_files_only=_lowercase						,     )
																				# Load config dict
																				if resolved_config_file is None:
																											raise EnvironmentError

																				__a		:		Optional[int]									=       Config.load_yaml(_lowercase							)

													except EnvironmentError:
																				__a		:		Dict									=       """Can't load config for"""
																				raise EnvironmentError(_lowercase							)

													if resolved_config_file == config_file:
																				print("""loading configuration file from path"""							)
													else:
																				print("""loading configuration file cache"""							)

													return Config.load_yaml(_lowercase							), kwargs







def       __magic_name__    (   _lowerCamelCase				: List[str]					):
							__a		:		Optional[Any]									=       torch.load("""dump.pt"""  ,       map_location=in_tensor.device					)
							__a		:		Union[str, Any]									=       in_tensor.numpy()
							__a		:		Dict									=       out_tensor.numpy()[0]
							print(na.shape  ,       na[0, 0, :5]					)
							print(na.shape  ,       na[0, 0, :5]					)
							assert np.allclose(_lowerCamelCase  ,       _lowerCamelCase  ,       rtol=0.01  ,       atol=0.1					), (
							    F'''{sum([1 for x in np.isclose(_lowerCamelCase  ,       _lowerCamelCase  ,       rtol=0.01  ,       atol=0.1					).flatten() if x is False]					)/len(na.flatten()					)*1_0_0:.4f} %'''
							    " element-wise mismatch"
							)
							raise Exception("""tensors are all good"""					)

							# Hugging face functions below





def       __magic_name__    (   _lowerCamelCase				: List[str]					):
							__a		:		List[str]									=       urlparse(_lowerCamelCase					)
							return parsed.scheme in ("http", "https")





def       __magic_name__    (   _lowerCamelCase				: str  ,       _lowerCamelCase				: str  ,       _lowerCamelCase				: Any=True					):
							__a		:		Tuple									=       CLOUDFRONT_DISTRIB_PREFIX if use_cdn else S3_BUCKET_PREFIX
							__a		:		List[str]									=       """/""" not in model_id
							if legacy_format:
														return F'''{endpoint}/{model_id}-{filename}'''
							else:
														return F'''{endpoint}/{model_id}/{filename}'''





def       __magic_name__    (   _lowerCamelCase				: Dict  ,       _lowerCamelCase				: Tuple  ,       _lowerCamelCase				: Dict=None  ,       _lowerCamelCase				: Union[str, Any]=0  ,       _lowerCamelCase				: str=None  ,       ):
							__a		:		str									=       """python/{}""".format(sys.version.split()[0]					)
							if _torch_available:
														ua += "; torch/{}".format(torch.__version__					)
							if isinstance(_lowerCamelCase  ,       _lowerCamelCase					):
														ua += "; " + "; ".join("""{}/{}""".format(_lowerCamelCase  ,       _lowerCamelCase					) for k, v in user_agent.items()					)
							elif isinstance(_lowerCamelCase  ,       _lowerCamelCase					):
														ua += "; " + user_agent
							__a		:		Tuple									=       {"""user-agent""": ua}
							if resume_size > 0:
														__a		:		Dict									=       """bytes=%d-""" % (resume_size,)
							__a		:		Tuple									=       requests.get(_lowerCamelCase  ,       stream=_lowerCamelCase  ,       proxies=_lowerCamelCase  ,       headers=_lowerCamelCase					)
							if response.status_code == 4_1_6:  # Range not satisfiable
														return
							__a		:		str									=       response.headers.get("""Content-Length"""					)
							__a		:		List[str]									=       resume_size + int(_lowerCamelCase					) if content_length is not None else None
							__a		:		List[str]									=       tqdm(
							    unit="""B"""  ,       unit_scale=_lowerCamelCase  ,       total=_lowerCamelCase  ,       initial=_lowerCamelCase  ,       desc="""Downloading"""  ,       )
							for chunk in response.iter_content(chunk_size=1_0_2_4					):
														if chunk:  # filter out keep-alive new chunks
																					progress.update(len(_lowerCamelCase					)					)
																					temp_file.write(_lowerCamelCase					)
							progress.close()





def       __magic_name__    (   _lowerCamelCase				: Any  ,       _lowerCamelCase				: List[Any]=None  ,       _lowerCamelCase				: Tuple=False  ,       _lowerCamelCase				: str=None  ,       _lowerCamelCase				: Optional[Any]=1_0  ,       _lowerCamelCase				: Union[str, Any]=False  ,       _lowerCamelCase				: List[str]=None  ,       _lowerCamelCase				: int=False  ,       ):
							if cache_dir is None:
														__a		:		List[Any]									=       TRANSFORMERS_CACHE
							if isinstance(_lowerCamelCase  ,       _lowerCamelCase					):
														__a		:		int									=       str(_lowerCamelCase					)

							os.makedirs(_lowerCamelCase  ,       exist_ok=_lowerCamelCase					)

							__a		:		Dict									=       None
							if not local_files_only:
														try:
																					__a		:		str									=       requests.head(_lowerCamelCase  ,       allow_redirects=_lowerCamelCase  ,       proxies=_lowerCamelCase  ,       timeout=_lowerCamelCase					)
																					if response.status_code == 2_0_0:
																												__a		:		Optional[int]									=       response.headers.get("""ETag"""					)
														except (EnvironmentError, requests.exceptions.Timeout):
																					# etag is already None
																					pass

							__a		:		Optional[Any]									=       url_to_filename(_lowerCamelCase  ,       _lowerCamelCase					)

							# get cache path to put the file
							__a		:		int									=       os.path.join(_lowerCamelCase  ,       _lowerCamelCase					)

							# etag is None = we don't have a connection, or url doesn't exist, or is otherwise inaccessible.
							# try to get the last downloaded one
							if etag is None:
														if os.path.exists(_lowerCamelCase					):
																					return cache_path
														else:
																					__a		:		Optional[Any]									=       [
																					    file
																					    for file in fnmatch.filter(os.listdir(_lowerCamelCase					)  ,       filename + """.*"""					)
																					    if not file.endswith(""".json"""					) and not file.endswith(""".lock"""					)
																					]
																					if len(_lowerCamelCase					) > 0:
																												return os.path.join(_lowerCamelCase  ,       matching_files[-1]					)
																					else:
																												# If files cannot be found and local_files_only=True,
																												# the models might've been found if local_files_only=False
																												# Notify the user about that
																												if local_files_only:
																																			raise ValueError(
																																			    """Cannot find the requested files in the cached path and outgoing traffic has been"""
																																			    """ disabled. To enable model look-ups and downloads online, set 'local_files_only'"""
																																			    """ to False."""					)
																												return None

    # From now on, etag is not None.
							if os.path.exists(_lowerCamelCase					) and not force_download:
														return cache_path

							# Prevent parallel downloads of the same file with a lock.
							__a		:		str									=       cache_path + """.lock"""
							with FileLock(_lowerCamelCase					):
														# If the download just completed while the lock was activated.
														if os.path.exists(_lowerCamelCase					) and not force_download:
																					# Even if returning early like here, the lock will be released.
																					return cache_path

														if resume_download:
																					__a		:		List[str]									=       cache_path + """.incomplete"""

																					@contextmanager
																					def _resumable_file_manager():
																												with open(_lowerCamelCase  ,       """a+b"""					) as f:
																																			yield f

																					__a		:		Tuple									=       _resumable_file_manager
																					if os.path.exists(_lowerCamelCase					):
																												__a		:		List[Any]									=       os.stat(_lowerCamelCase					).st_size
																					else:
																												__a		:		int									=       0
														else:
																					__a		:		Union[str, Any]									=       partial(tempfile.NamedTemporaryFile  ,       dir=_lowerCamelCase  ,       delete=_lowerCamelCase					)
																					__a		:		Optional[int]									=       0

														# Download to temporary file, then copy to cache dir once finished.
														# Otherwise you get corrupt cache entries if the download gets interrupted.
														with temp_file_manager() as temp_file:
																					print(
																					    """%s not found in cache or force_download set to True, downloading to %s"""  ,       _lowerCamelCase  ,       temp_file.name  ,       )

																					http_get(
																					    _lowerCamelCase  ,       _lowerCamelCase  ,       proxies=_lowerCamelCase  ,       resume_size=_lowerCamelCase  ,       user_agent=_lowerCamelCase  ,       )

														os.replace(temp_file.name  ,       _lowerCamelCase					)

														__a		:		Optional[Any]									=       {"""url""": url, """etag""": etag}
														__a		:		Optional[Any]									=       cache_path + """.json"""
														with open(_lowerCamelCase  ,       """w"""					) as meta_file:
																					json.dump(_lowerCamelCase  ,       _lowerCamelCase					)

							return cache_path





def       __magic_name__    (   _lowerCamelCase				: Union[str, Any]  ,       _lowerCamelCase				: Optional[Any]=None					):
							__a		:		str									=       url.encode("""utf-8"""					)
							__a		:		str									=       shaaaa(_lowerCamelCase					)
							__a		:		int									=       url_hash.hexdigest()

							if etag:
														__a		:		Tuple									=       etag.encode("""utf-8"""					)
														__a		:		Any									=       shaaaa(_lowerCamelCase					)
														filename += "." + etag_hash.hexdigest()

							if url.endswith(""".h5"""					):
														filename += ".h5"

							return filename





def       __magic_name__    (   _lowerCamelCase				: Union[str, Any]  ,       _lowerCamelCase				: Optional[int]=None  ,       _lowerCamelCase				: Dict=False  ,       _lowerCamelCase				: Tuple=None  ,       _lowerCamelCase				: Union[str, Any]=False  ,       _lowerCamelCase				: List[str]=None  ,       _lowerCamelCase				: int=False  ,       _lowerCamelCase				: Union[str, Any]=False  ,       _lowerCamelCase				: Dict=False  ,       ):
							if cache_dir is None:
														__a		:		int									=       TRANSFORMERS_CACHE
							if isinstance(_lowerCamelCase  ,       _lowerCamelCase					):
														__a		:		Tuple									=       str(_lowerCamelCase					)
							if isinstance(_lowerCamelCase  ,       _lowerCamelCase					):
														__a		:		Union[str, Any]									=       str(_lowerCamelCase					)

							if is_remote_url(_lowerCamelCase					):
														# URL, so get it from the cache (downloading if necessary)
														__a		:		Optional[Any]									=       get_from_cache(
														    _lowerCamelCase  ,       cache_dir=_lowerCamelCase  ,       force_download=_lowerCamelCase  ,       proxies=_lowerCamelCase  ,       resume_download=_lowerCamelCase  ,       user_agent=_lowerCamelCase  ,       local_files_only=_lowerCamelCase  ,       )
							elif os.path.exists(_lowerCamelCase					):
														# File, and it exists.
														__a		:		Union[str, Any]									=       url_or_filename
							elif urlparse(_lowerCamelCase					).scheme == "":
														# File, but it doesn't exist.
														raise EnvironmentError("""file {} not found""".format(_lowerCamelCase					)					)
							else:
														# Something unknown
														raise ValueError("""unable to parse {} as a URL or as a local path""".format(_lowerCamelCase					)					)

							if extract_compressed_file:
														if not is_zipfile(_lowerCamelCase					) and not tarfile.is_tarfile(_lowerCamelCase					):
																					return output_path

														# Path where we extract compressed archives
														# We avoid '.' in dir name and add "-extracted" at the end: "./model.zip" => "./model-zip-extracted/"
														__a							,     __a		:		Dict									=       os.path.split(_lowerCamelCase					)
														__a		:		int									=       output_file.replace("""."""  ,       """-"""					) + """-extracted"""
														__a		:		Any									=       os.path.join(_lowerCamelCase  ,       _lowerCamelCase					)

														if os.path.isdir(_lowerCamelCase					) and os.listdir(_lowerCamelCase					) and not force_extract:
																					return output_path_extracted

														# Prevent parallel extractions
														__a		:		List[str]									=       output_path + """.lock"""
														with FileLock(_lowerCamelCase					):
																					shutil.rmtree(_lowerCamelCase  ,       ignore_errors=_lowerCamelCase					)
																					os.makedirs(_lowerCamelCase					)
																					if is_zipfile(_lowerCamelCase					):
																												with ZipFile(_lowerCamelCase  ,       """r"""					) as zip_file:
																																			zip_file.extractall(_lowerCamelCase					)
																																			zip_file.close()
																					elif tarfile.is_tarfile(_lowerCamelCase					):
																												__a		:		Union[str, Any]									=       tarfile.open(_lowerCamelCase					)
																												tar_file.extractall(_lowerCamelCase					)
																												tar_file.close()
																					else:
																												raise EnvironmentError("""Archive format of {} could not be identified""".format(_lowerCamelCase					)					)

														return output_path_extracted

							return output_path





def       __magic_name__    (   _lowerCamelCase				: Any  ,       _lowerCamelCase				: List[str]=","					):
							assert isinstance(_lowerCamelCase  ,       _lowerCamelCase					)
							if os.path.isfile(_lowerCamelCase					):
														with open(_lowerCamelCase					) as f:
																					__a		:		Dict									=       eval(f.read()					)
							else:
														__a		:		List[Any]									=       requests.get(_lowerCamelCase					)
														try:
																					__a		:		Tuple									=       requests.json()
														except Exception:
																					__a		:		Optional[Any]									=       req.content.decode()
																					assert data is not None, "could not connect"
																					try:
																												__a		:		Optional[int]									=       eval(_lowerCamelCase					)
																					except Exception:
																												__a		:		Tuple									=       data.split("""\n"""					)
														req.close()
							return data





def       __magic_name__    (   _lowerCamelCase				: Optional[Any]					):
							__a		:		Any									=       requests.get(_lowerCamelCase					)
							__a		:		Optional[int]									=       np.array(Image.open(BytesIO(response.content					)					)					)
							return img





def       __magic_name__    (   _lowerCamelCase				: Union[str, Any]					):
							__a		:		Tuple									=       url.split("""/"""					)[-1]
							if fn not in os.listdir(os.getcwd()					):
														wget.download(_lowerCamelCase					)
							with open(_lowerCamelCase  ,       """rb"""					) as stream:
														__a		:		List[Any]									=       pkl.load(_lowerCamelCase					)
							__a		:		Tuple									=       weights.pop("""model"""					)
							__a		:		str									=       {}
							for k, v in model.items():
														__a		:		List[Any]									=       torch.from_numpy(_lowerCamelCase					)
														if "running_var" in k:
																					__a		:		Union[str, Any]									=       torch.tensor([0]					)
																					__a		:		Dict									=       k.replace("""running_var"""  ,       """num_batches_tracked"""					)
																					__a		:		Tuple									=       zero
							return new





def       __magic_name__    (   ):
							print(F'''{os.path.abspath(os.path.join(_lowerCamelCase  ,       os.pardir					)					)}/demo.ipynb'''					)





def       __magic_name__    (   _lowerCamelCase				: Union[str, Any]  ,       _lowerCamelCase				: Tuple="RGB"					):
							assert isinstance(_lowerCamelCase  ,       _lowerCamelCase					)
							if os.path.isfile(_lowerCamelCase					):
														__a		:		List[Any]									=       cva.imread(_lowerCamelCase					)
							else:
														__a		:		Optional[Any]									=       get_image_from_url(_lowerCamelCase					)
														assert img is not None, F'''could not connect to: {im}'''
							__a		:		Tuple									=       cva.cvtColor(_lowerCamelCase  ,       cva.COLOR_BGR2RGB					)
							if input_format == "RGB":
														__a		:		Dict									=       img[:, :, ::-1]
							return img







def       __magic_name__    (   _lowerCamelCase				: Any  ,       _lowerCamelCase				: Optional[Any]=1					):
							return (images[i : i + batch] for i in range(0  ,       len(_lowerCamelCase					)  ,       _lowerCamelCase					))






"""simple docstring"""

import functools
import operator

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


lowercase__			   =  logging.get_logger(__name__)

lowercase__			   =  {
    "microsoft/unispeech-large-1500h-cv": (
        "https://huggingface.co/microsoft/unispeech-large-1500h-cv/resolve/main/config.json"
    ),
    # See all UniSpeech models at https://huggingface.co/models?filter=unispeech
}




class SCREAMING_SNAKE_CASE__					(		__snake_case      ):
						_lowerCAmelCase							=					"unispeech"



						def __init__(self						,     _lowercase=32						,     _lowercase=768						,     _lowercase=12						,     _lowercase=12						,     _lowercase=3072						,     _lowercase="gelu"						,     _lowercase=0.1						,     _lowercase=0.1						,     _lowercase=0.1						,     _lowercase=0.0						,     _lowercase=0.0						,     _lowercase=0.1						,     _lowercase=0.1						,     _lowercase=0.02						,     _lowercase=1e-5						,     _lowercase="group"						,     _lowercase="gelu"						,     _lowercase=(512, 512, 512, 512, 512, 512, 512)						,     _lowercase=(5, 2, 2, 2, 2, 2, 2)						,     _lowercase=(10, 3, 3, 3, 3, 2, 2)						,     _lowercase=False						,     _lowercase=128						,     _lowercase=16						,     _lowercase=False						,     _lowercase=True						,     _lowercase=0.05						,     _lowercase=10						,     _lowercase=2						,     _lowercase=0.0						,     _lowercase=10						,     _lowercase=0						,     _lowercase=320						,     _lowercase=2						,     _lowercase=0.1						,     _lowercase=100						,     _lowercase=256						,     _lowercase=256						,     _lowercase=0.1						,     _lowercase="mean"						,     _lowercase=False						,     _lowercase=False						,     _lowercase=256						,     _lowercase=80						,     _lowercase=0						,     _lowercase=1						,     _lowercase=2						,     _lowercase=0.5						,     **_lowercase						,     ):





													'''simple docstring'''

													super().__init__(**_lowercase						,     pad_token_id=_lowercase						,     bos_token_id=_lowercase						,     eos_token_id=_lowercase							)
													__a		:		Union[str, Any]									=       hidden_size
													__a		:		Any									=       feat_extract_norm
													__a		:		Union[str, Any]									=       feat_extract_activation
													__a		:		Tuple									=       list(_lowercase							)
													__a		:		Dict									=       list(_lowercase							)
													__a		:		List[Any]									=       list(_lowercase							)
													__a		:		List[Any]									=       conv_bias
													__a		:		Optional[Any]									=       num_conv_pos_embeddings
													__a		:		Union[str, Any]									=       num_conv_pos_embedding_groups
													__a		:		Dict									=       len(self.conv_dim							)
													__a		:		Dict									=       num_hidden_layers
													__a		:		Union[str, Any]									=       intermediate_size
													__a		:		List[str]									=       hidden_act
													__a		:		int									=       num_attention_heads
													__a		:		int									=       hidden_dropout
													__a		:		Any									=       attention_dropout
													__a		:		List[Any]									=       activation_dropout
													__a		:		List[Any]									=       feat_proj_dropout
													__a		:		Union[str, Any]									=       final_dropout
													__a		:		str									=       layerdrop
													__a		:		Dict									=       layer_norm_eps
													__a		:		Dict									=       initializer_range
													__a		:		Union[str, Any]									=       num_ctc_classes
													__a		:		List[Any]									=       vocab_size
													__a		:		Any									=       do_stable_layer_norm
													__a		:		List[str]									=       use_weighted_layer_sum
													__a		:		List[str]									=       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
													__a		:		Dict									=       apply_spec_augment
													__a		:		Union[str, Any]									=       mask_time_prob
													__a		:		List[str]									=       mask_time_length
													__a		:		Dict									=       mask_time_min_masks
													__a		:		List[Any]									=       mask_feature_prob
													__a		:		Tuple									=       mask_feature_length
													__a		:		int									=       mask_feature_min_masks

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

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

													# pretraining loss
													__a		:		Tuple									=       replace_prob





						@property
						def     lowerCAmelCase__(self							):





													'''simple docstring'''

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

