o
    i)                     @   s   d Z ddlZddlmZ ddlmZ dedefddZdedefd	d
ZdedefddZdedefddZ	dedefddZ
dedefddZdedefddZdedefddZdedefddZdS )zTransducer model arguments.    N)_ArgumentGroup)	strtoboolgroupreturnc                 C   s.   | j ddtg ddd | j ddtdd	 | S )
%Define general arguments for encoder.z--etypeblstmp)customlstmblstmlstmpr   vgglstmp	vggblstmpvgglstmvggblstmgrubgrugrupbgrupvgggrupvggbgrupvgggruvggbgruz$Type of encoder network architecturedefaulttypechoiceshelpz--dropout-rate        zDropout rate for the encoderr   r   r   add_argumentstrfloatr    r$   d/home/ubuntu/.local/lib/python3.10/site-packages/espnet/nets/pytorch_backend/transducer/arguments.pyadd_encoder_general_arguments   s   r&   c                 C   sN   | j ddtdd | j dddtdd | j d	d
tdd | j ddtdd | S )z!Define arguments for RNN encoder.z	--elayers   zPNumber of encoder layers (for shared recognition part in multi-speaker asr mode)r   z--eunitsz-ui,  zNumber of encoder hidden unitsz--eprojs@  z"Number of encoder projection unitsz--subsample1zhSubsample input frames x_y_z means subsample every x frame at 1st layer, every y frame at 2nd layer etc.)r    intr!   r#   r$   r$   r%   add_rnn_encoder_arguments-   s.   r+   c                 C   s   | j dtdddd | j ddtdd	 | j d
tdg ddd | j dtddd | j dtddd | j dtdg ddd | j dtdddgdd | j dtdg dd d | j d!td"g dd#d | S )$z$Define arguments for Custom encoder.z--enc-block-archappendNz)Encoder architecture definition by blocksr   actionr   r   z--enc-block-repeat   z3Repeat N times the provided encoder blocks if N > 1r   z--custom-enc-input-layerconv2d)r0   vgg2llinearembedzCustom encoder input layer typer   r   r   r   z--custom-enc-input-dropout-rater   z*Dropout rate of custom encoder input layer)r   r   r   z'--custom-enc-input-pos-enc-dropout-ratezADropout rate of positional encoding in custom encoder input layerz%--custom-enc-positional-encoding-typeabs_pos)r5   scaled_abs_posrel_posz-Custom encoder positional encoding layer typez--custom-enc-self-attn-type	self_attnrel_self_attnz"Custom encoder self-attention typez--custom-enc-pw-activation-typerelur:   hardtanhseluswishz(Custom encoder pointwise activation typez%--custom-enc-conv-mod-activation-typer>   z3Custom encoder convolutional module activation type)r    evalr*   r!   r"   r#   r$   r$   r%   add_custom_encoder_argumentsK   sz   r@   c                 C   s@   | j ddtg ddd | j ddtdd	 | j d
dtdd	 | S )r   z--dtyper	   )r	   r   r   zType of decoder to user   z--dropout-rate-decoderr   zDropout rate for the decoderr   z--dropout-rate-embed-decoderz,Dropout rate for the decoder embedding layerr   r#   r$   r$   r%   add_decoder_general_arguments   s(   rA   c                 C   s:   | j ddtdd | j ddtdd | j ddtd	d | S )
z!Define arguments for RNN decoder.z--dec-embed-dimr(   z'Number of decoder embeddings dimensionsr   z	--dlayersr/   zNumber of decoder layersz--dunitszNumber of decoder hidden units)r    r*   r#   r$   r$   r%   add_rnn_decoder_arguments   s   rB   c                 C   sZ   | j dtdddd | j ddtdd	 | j d
tdddgdd | j dtdg ddd | S )z$Define arguments for Custom decoder.z--dec-block-archr,   Nz Custom decoder blocks definitionr-   z--dec-block-repeatr/   z3Repeat N times the provided decoder blocks if N > 1r   z--custom-dec-input-layerr3   r2   zCustom decoder input layer typer4   z--custom-dec-pw-activation-typer:   r;   z(Custom decoder pointwise activation type)r    r?   r*   r!   r#   r$   r$   r%   add_custom_decoder_arguments   s8   rC   c                 C   sp   | j ddtdd | j ddtdd | j dd	td
d | j dtddd | j dtddd | j dtddd | S )z7Define arguments for training with Custom architecture.z--optimizer-warmup-stepsia  zOptimizer warmup stepsr   z	--noam-lrg      $@zInitial value of learning ratez--noam-adimr   z0Most dominant attention dimension for scheduler.z--transformer-warmup-stepszaOptimizer warmup steps. The parameter is deprecated, please use --optimizer-warmup-steps instead.optimizer_warmup_steps)r   r   destz--transformer-lrzZInitial value of learning rate. The parameter is deprecated, please use --noam-lr instead.noam_lrz--adimzmMost dominant attention dimension for scheduler. The parameter is deprecated, please use --noam-adim instead.	noam_adim)r    r*   r"   r#   r$   r$   r%   add_custom_training_arguments   sJ   rH   c                 C   sf   | j ddtdd | j ddtdd | j dtd	g d
dd | j dtdddd | j ddtdd | S )z.Define general arguments for Transducer model.z--transducer-weightg      ?zWeight of main Transducer loss.r   z--joint-dimr(   z#Number of dimensions in joint spacez--joint-activation-typetanh)r:   rI   r>   zJoint network activation typer4   z--score-norm?Tz%Normalize Transducer scores by lengthr   nargsr   r   z--fastemit-lambdar   zHRegularization parameter for FastEmit (https://arxiv.org/abs/2010.11148))r    r"   r*   r!   r   r#   r$   r$   r%   add_transducer_arguments  sB   rM   c                 C   s   | j dtdddd | j ddtdd	 | j d
dtdd	 | j dtdddd | j ddtdd	 | j ddtdd	 | j dtdddd | j ddtdd	 | j ddtjdd	 | j ddtdd	 | j ddtdd	 | j d tddd!d | j d"dtd#d	 | S )$z!Add arguments for auxiliary task.z--use-ctc-lossrJ   Fz&Whether to compute auxiliary CTC loss.rK   z--ctc-loss-weightg      ?zWeight of auxiliary CTC loss.r   z--ctc-loss-dropout-rater   zDropout rate for auxiliary CTC.z--use-lm-lossz7Whether to compute auxiliary LM loss (label smoothing).z--lm-loss-weightzWeight of auxiliary LM loss.z--lm-loss-smoothing-ratez?Smoothing rate for LM loss. If > 0, label smoothing is enabled.z--use-aux-transducer-lossz-Whether to compute auxiliary Transducer loss.z--aux-transducer-loss-weightg?z$Weight of auxiliary Transducer loss.z'--aux-transducer-loss-enc-output-layersNzNList of intermediate encoder layers for auxiliary transducer loss computation.z--aux-transducer-loss-mlp-dimr(   zEMultilayer perceptron hidden dimension for auxiliary Transducer loss.z&--aux-transducer-loss-mlp-dropout-ratezAMultilayer perceptron dropout rate for auxiliary Transducer loss.z--use-symm-kl-div-lossz0Whether to compute symmetric KL divergence loss.z--symm-kl-div-loss-weightz'Weight of symmetric KL divergence loss.)r    r   r"   astliteral_evalr*   r#   r$   r$   r%   add_auxiliary_task_arguments,  s   rP   )__doc__rN   argparser   distutils.utilr   r&   r+   r@   rA   rB   rC   rH   rM   rP   r$   r$   r$   r%   <module>   s    %B!-&