



"""simple docstring"""

import functools
import operator

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


lowercase__			   =  logging.get_logger(__name__)

lowercase__			   =  {
    "asapp/sew-d-tiny-100k": "https://huggingface.co/asapp/sew-d-tiny-100k/resolve/main/config.json",
    # See all SEW-D models at https://huggingface.co/models?filter=sew-d
}




class SCREAMING_SNAKE_CASE__					(		_lowercase      ):
						_lowerCAmelCase							=					'''sew-d'''



						def __init__(self						,     _lowercase=32						,     _lowercase=768						,     _lowercase=12						,     _lowercase=12						,     _lowercase=3072						,     _lowercase=2						,     _lowercase=512						,     _lowercase=256						,     _lowercase=True						,     _lowercase=True						,     _lowercase=("p2c", "c2p")						,     _lowercase="layer_norm"						,     _lowercase="gelu_python"						,     _lowercase=0.1						,     _lowercase=0.1						,     _lowercase=0.1						,     _lowercase=0.0						,     _lowercase=0.1						,     _lowercase=0.02						,     _lowercase=1e-7						,     _lowercase=1e-5						,     _lowercase="group"						,     _lowercase="gelu"						,     _lowercase=(64, 128, 128, 128, 128, 256, 256, 256, 256, 512, 512, 512, 512)						,     _lowercase=(5, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1)						,     _lowercase=(10, 3, 1, 3, 1, 3, 1, 3, 1, 2, 1, 2, 1)						,     _lowercase=False						,     _lowercase=128						,     _lowercase=16						,     _lowercase=True						,     _lowercase=0.05						,     _lowercase=10						,     _lowercase=2						,     _lowercase=0.0						,     _lowercase=10						,     _lowercase=0						,     _lowercase="mean"						,     _lowercase=False						,     _lowercase=False						,     _lowercase=256						,     _lowercase=0						,     _lowercase=1						,     _lowercase=2						,     **_lowercase						,     ):





													'''simple docstring'''

													super().__init__(**A_						,     pad_token_id=A_						,     bos_token_id=A_						,     eos_token_id=A_							)
													__a		:		List[str]									=       hidden_size
													__a		:		List[Any]									=       feat_extract_norm
													__a		:		List[str]									=       feat_extract_activation
													__a		:		Union[str, Any]									=       list(A_							)
													__a		:		Dict									=       list(A_							)
													__a		:		Optional[Any]									=       list(A_							)
													__a		:		Any									=       conv_bias
													__a		:		Union[str, Any]									=       num_conv_pos_embeddings
													__a		:		str									=       num_conv_pos_embedding_groups
													__a		:		Any									=       len(self.conv_dim							)
													__a		:		Union[str, Any]									=       num_hidden_layers
													__a		:		int									=       intermediate_size
													__a		:		Optional[int]									=       squeeze_factor
													__a		:		Tuple									=       max_position_embeddings
													__a		:		List[Any]									=       position_buckets
													__a		:		int									=       share_att_key
													__a		:		Union[str, Any]									=       relative_attention
													__a		:		Optional[Any]									=       norm_rel_ebd
													__a		:		str									=       list(A_							)
													__a		:		Union[str, Any]									=       hidden_act
													__a		:		Dict									=       num_attention_heads
													__a		:		Union[str, Any]									=       hidden_dropout
													__a		:		Optional[int]									=       attention_dropout
													__a		:		List[Any]									=       activation_dropout
													__a		:		List[Any]									=       feat_proj_dropout
													__a		:		Tuple									=       final_dropout
													__a		:		List[str]									=       layer_norm_eps
													__a		:		Tuple									=       feature_layer_norm_eps
													__a		:		List[str]									=       initializer_range
													__a		:		List[Any]									=       vocab_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)`,"""
																				    F'''but is `len(config.conv_dim) = {len(self.conv_dim							)}`, `len(config.conv_stride)'''
																				    F'''= {len(self.conv_stride							)}`, `len(config.conv_kernel) = {len(self.conv_kernel							)}`.'''							)

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

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

													# sequence classification
													__a		:		Dict									=       use_weighted_layer_sum
													__a		:		Tuple									=       classifier_proj_size





						@property
						def     lowerCAmelCase__(self							):





													'''simple docstring'''

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






"""simple docstring"""

from manim import *




class SCREAMING_SNAKE_CASE__					(		__snake_case      ):



						def     lowerCAmelCase__(self							):





													'''simple docstring'''

													__a		:		List[str]									=       Rectangle(height=0.5						,     width=0.5							)
													__a		:		Union[str, Any]									=       Rectangle(height=0.25						,     width=0.25							)
													__a		:		Dict									=       Rectangle(height=0.46						,     width=0.46							).set_stroke(width=0							)

													__a		:		Dict									=       [mem.copy() for i in range(6							)]
													__a		:		str									=       [mem.copy() for i in range(6							)]
													__a		:		Tuple									=       VGroup(*_lowercase							).arrange(_lowercase						,     buff=0							)
													__a		:		List[Any]									=       VGroup(*_lowercase							).arrange(_lowercase						,     buff=0							)
													__a		:		List[Any]									=       VGroup(_lowercase						,     _lowercase							).arrange(_lowercase						,     buff=0							)
													__a		:		Union[str, Any]									=       Text("""CPU"""						,     font_size=24							)
													__a		:		Dict									=       Group(_lowercase						,     _lowercase							).arrange(_lowercase						,     buff=0.5						,     aligned_edge=_lowercase							)
													cpu.move_to([-2.5, -0.5, 0]							)
													self.add(_lowercase							)

													__a		:		Optional[Any]									=       [mem.copy() for i in range(4							)]
													__a		:		Dict									=       VGroup(*_lowercase							).arrange(_lowercase						,     buff=0							)
													__a		:		List[str]									=       Text("""GPU"""						,     font_size=24							)
													__a		:		Any									=       Group(_lowercase						,     _lowercase							).arrange(_lowercase						,     buff=0.5						,     aligned_edge=_lowercase							)
													gpu.move_to([-1, -1, 0]							)
													self.add(_lowercase							)

													__a		:		List[Any]									=       [mem.copy() for i in range(6							)]
													__a		:		Any									=       VGroup(*_lowercase							).arrange(_lowercase						,     buff=0							)

													__a		:		Optional[Any]									=       Text("""Model"""						,     font_size=24							)
													__a		:		Any									=       Group(_lowercase						,     _lowercase							).arrange(_lowercase						,     buff=0.5						,     aligned_edge=_lowercase							)
													model.move_to([3, -1.0, 0]							)
													self.add(_lowercase							)

													__a		:		Tuple									=       []
													__a		:		Tuple									=       []
													__a		:		Optional[int]									=       []

													for i, rect in enumerate(_lowercase							):
																				rect.set_stroke(_lowercase							)

																				__a		:		str									=       Rectangle(height=0.46 / 4						,     width=0.46 / 3							).set_stroke(width=0.0							).set_fill(_lowercase						,     opacity=0.7							)

																				if i == 0:
																											cpu_target.next_to(cpu_left_col_base[0].get_corner(DOWN + LEFT							)						,     buff=0.02						,     direction=_lowercase							)
																											cpu_target.set_x(cpu_target.get_x() + 0.1							)
																				elif i == 3:
																											cpu_target.next_to(model_cpu_arr[0]						,     direction=_lowercase						,     buff=0.0							)
																				else:
																											cpu_target.next_to(model_cpu_arr[i - 1]						,     direction=_lowercase						,     buff=0.0							)
																				self.add(_lowercase							)
																				model_cpu_arr.append(_lowercase							)

													self.add(*_lowercase						,     *_lowercase						,     *_lowercase							)

													__a		:		Optional[Any]									=       [mem.copy() for i in range(6							)]
													__a		:		Union[str, Any]									=       VGroup(*_lowercase							).arrange(_lowercase						,     buff=0							)

													__a		:		Any									=       Text("""Loaded Checkpoint"""						,     font_size=24							)
													__a		:		str									=       Group(_lowercase						,     _lowercase							).arrange(_lowercase						,     buff=0.5						,     aligned_edge=_lowercase							)
													checkpoint.move_to([3, 0.5, 0]							)

													self.add(_lowercase							)

													__a		:		Dict									=       []
													__a		:		int									=       []

													for i, rect in enumerate(_lowercase							):
																				__a		:		List[str]									=       fill.copy().set_fill(_lowercase						,     opacity=0.7							)
																				target.move_to(_lowercase							)
																				ckpt_arr.append(_lowercase							)

																				__a		:		Union[str, Any]									=       target.copy()
																				if i < 5:
																											cpu_target.move_to(cpu_left_col_base[i + 1]							)
																				else:
																											cpu_target.move_to(cpu_right_col_base[i - 5]							)
																				ckpt_cpu_arr.append(_lowercase							)
													self.add(*_lowercase						,     *_lowercase							)

													__a		:		List[str]									=       Square(side_length=2.2							)
													key.move_to([-5, 2, 0]							)

													__a		:		List[Any]									=       MarkupText(
													    F'''<b>Key:</b>\n\n<span fgcolor=\'{YELLOW}\'>●</span> Empty Model'''						,     font_size=18						,     )

													key_text.move_to([-5, 2.4, 0]							)

													self.add(_lowercase						,     _lowercase							)

													__a		:		str									=       MarkupText(
													    F'''<span fgcolor=\'{BLUE}\'>●</span> Checkpoint'''						,     font_size=18						,     )

													blue_text.next_to(_lowercase						,     DOWN * 2.4						,     aligned_edge=key_text.get_left()							)
													self.add(_lowercase							)

													__a		:		Optional[int]									=       MarkupText(
													    F'''Based on the passed in configuration, weights are stored in\na variety of np.memmaps on disk or to a particular device.'''						,     font_size=24						,     )
													step_a.move_to([2, 2, 0]							)

													__a		:		List[Any]									=       [meta_mem.copy() for i in range(6							)]
													__a		:		Optional[int]									=       [meta_mem.copy() for i in range(6							)]
													__a		:		List[Any]									=       VGroup(*_lowercase							).arrange(_lowercase						,     buff=0							)
													__a		:		List[str]									=       VGroup(*_lowercase							).arrange(_lowercase						,     buff=0							)
													__a		:		Tuple									=       VGroup(_lowercase						,     _lowercase							).arrange(_lowercase						,     buff=0							)
													__a		:		Dict									=       Text("""Disk"""						,     font_size=24							)
													__a		:		Dict									=       Group(_lowercase						,     _lowercase							).arrange(_lowercase						,     buff=0.5						,     aligned_edge=_lowercase							)
													disk.move_to([-4.0, -1.25, 0]							)
													self.play(Write(_lowercase						,     run_time=3							)						,     Write(_lowercase						,     run_time=1							)						,     Create(_lowercase						,     run_time=1							)							)

													__a		:		Optional[Any]									=       []
													for i, rect in enumerate(_lowercase							):
																				__a		:		List[str]									=       rect.copy()
																				target.generate_target()
																				target.target.move_to(disk_left_col_base[i]							).scale(0.5							)
																				animations.append(MoveToTarget(_lowercase						,     run_time=1.5							)							)
													self.play(*_lowercase							)

													self.play(FadeOut(_lowercase							)							)

													__a		:		List[str]									=       MarkupText(F'''Then, the checkpoint is removed from memory\nthrough garbage collection.'''						,     font_size=24							)
													step_a.move_to([2, 2, 0]							)

													self.play(Write(_lowercase						,     run_time=3							)							)

													self.play(
													    FadeOut(_lowercase						,     _lowercase						,     *_lowercase						,     *_lowercase							)						,     )

													self.wait()

