o
    }oi
                     @   s,   d dl mZmZ d dlZG dd deZdS )    )ABCabstractmethodNc                   @   sP   e Zd Ze	ddefddZedd Zedd Z									
		dddZ	d	S )StreamingEncoder'  max_look_aheadc                 C   s   dS )a  
        This function sets the needed values and parameters to perform streaming. The configuration (CacheAwareStreamingConfig) need to be stored in self.streaming_cfg.
        The streaming configuration is needed to simulate streaming inference. It would set the following
        N )selfr   r   r   _/home/ubuntu/.local/lib/python3.10/site-packages/nemo/collections/asr/parts/mixins/streaming.pysetup_streaming_params   s   z'StreamingEncoder.setup_streaming_paramsc                 C   s   d S Nr   )r   
batch_sizedtypedevicemax_dimr   r   r	   get_initial_cache_state   s   z(StreamingEncoder.get_initial_cache_statec                 C   s.   | d u rd S | j r|    S |   S r   )requires_graddetachcpunumpy)tensorr   r   r	   to_numpy#   s   "zStreamingEncoder.to_numpyNTc           
      C   s   | j d u r	|   |d ur| j j}|| j _nd }|d u r(||d|d}| |||||d}	| j|	|d}	|d ur@|| j _|	S )Nr   )audio_signallengthcache_last_channelcache_last_timecache_last_channel_len)keep_all_outputs)streaming_cfgr
   drop_extra_pre_encodednew_fullsizestreaming_post_process)
r   processed_signalprocessed_signal_lengthr   r   r   r   r   prev_drop_extra_pre_encodedencoder_outputr   r   r	   cache_aware_stream_step)   s&   


z(StreamingEncoder.cache_aware_stream_step)r   )NNNNTN)
__name__
__module____qualname__r   intr
   r   staticmethodr   r'   r   r   r   r	   r      s"    	

r   )abcr   r   torchr   r   r   r   r	   <module>   s   