o
    i*                     @   sD   d dl Z d dlmZ d dlmZ eddG dd de jjZdS )    N)tables)get_activationjoint_network_classesjoint_networkc                       sd   e Zd ZdZ		ddededededed	d
f fddZ	ddejdejde	d	ejfddZ
  ZS )JointNetworka]  Transducer joint network module.

    Args:
        output_size: Output size.
        encoder_size: Encoder output size.
        decoder_size: Decoder output size..
        joint_space_size: Joint space size.
        joint_act_type: Type of activation for joint network.
        **activation_parameters: Parameters for the activation function.

       tanhoutput_sizeencoder_sizedecoder_sizejoint_space_sizejoint_activation_typereturnNc                    sL   t    tj||| _tjj||dd| _tj||| _t|| _	dS )z Construct a JointNetwork object.F)biasN)
super__init__torchnnLinearlin_enclin_declin_outr   joint_activation)selfr	   r
   r   r   r   	__class__ Z/home/ubuntu/.local/lib/python3.10/site-packages/funasr/models/transducer/joint_network.pyr      s
   
	zJointNetwork.__init__Tenc_outdec_outproject_inputc                 C   s8   |r|  | || | }n|  || }| |S )aM  Joint computation of encoder and decoder hidden state sequences.

        Args:
            enc_out: Expanded encoder output state sequences (B, T, 1, D_enc)
            dec_out: Expanded decoder output state sequences (B, 1, U, D_dec)

        Returns:
            joint_out: Joint output state sequences. (B, T, U, D_out)

        )r   r   r   r   )r   r   r   r    	joint_outr   r   r   forward,   s   
zJointNetwork.forward)r   r   )T)__name__
__module____qualname____doc__intstrr   r   Tensorboolr"   __classcell__r   r   r   r   r      s6    r   )	r   funasr.registerr   *funasr.models.transformer.utils.nets_utilsr   registerr   Moduler   r   r   r   r   <module>   s
   
