+
    &ja                        ^ RI Ht ^ RIt^ RIHt ^ RIt. ROt]! RRR7      t]! RRR7      tRR	 R
 llt	RR R llt
R R ltR R ltR# )    )annotationsN)TypeVarConvTztorch.nn.modules.conv._ConvNd)boundLinearTztorch.nn.Linearc               (    V ^8  d   QhRRRRRRRR/# )   convr   bn%torch.nn.modules.batchnorm._BatchNorm	transposeboolreturn )formats   "m/Users/jameslopez/projects/CWCArchive/cwc-podcast/.venv/lib/python3.14/site-packages/torch/nn/utils/fusion.py__annotate__r      s0     # #
#-# # 	#    c           
        V P                   '       g   VP                   '       d   \        R4      h\        P                  ! V 4      pVP                  e   VP
                  f   \        R4      h\        VP                  VP                  VP                  VP
                  VP                  VP                  VP                  V4      w  Vn        Vn        V# )a  Fuse a convolutional module and a BatchNorm module into a single, new convolutional module.

Args:
    conv (torch.nn.modules.conv._ConvNd): A convolutional module.
    bn (torch.nn.modules.batchnorm._BatchNorm): A BatchNorm module.
    transpose (bool, optional): If True, transpose the convolutional weight. Defaults to False.

Returns:
    torch.nn.modules.conv._ConvNd: The fused convolutional module.

.. note::
    Both ``conv`` and ``bn`` must be in eval mode, and ``bn`` must have its running buffers computed.
Fusion only for eval!3bn.running_mean and bn.running_var must not be None)
trainingAssertionErrorcopydeepcopyrunning_meanrunning_varfuse_conv_bn_weightsweightbiaseps)r
   r   r   
fused_convs   &&& r   fuse_conv_bn_evalr#      s    $ }}}455t$J	".."8RSS)=



		
	*&Jz r   c               <    V ^8  d   QhRRRRRRRRRRR	RR
RRRRR/	# )r	   conv_wtorch.Tensorconv_btorch.Tensor | Nonebn_rmbn_rvbn_epsfloatbn_wbn_br   r   r   -tuple[torch.nn.Parameter, torch.nn.Parameter]r   )r   s   "r   r   r   :   sb     2 222 2 	2
 2 2 2 2 32r   c                2   V P                   pVe   VP                   MTp	Vf   \        P                  ! V4      pVf   \        P                  ! V4      pVf   \        P                  ! V4      p\        P                  ! W4,           4      p
V'       d/   ^R.^.\        V P                  4      ^,
          ,          ,           pM-R^.^.\        V P                  4      ^,
          ,          ,           pWV
,          P                  V4      ,          P                  VR7      pW,
          V
,          V,          V,           P                  V	R7      p\        P                  P                  WP                  4      \        P                  P                  WP                  4      3# )a  Fuse convolutional module parameters and BatchNorm module parameters into new convolutional module parameters.

Args:
    conv_w (torch.Tensor): Convolutional weight.
    conv_b (Optional[torch.Tensor]): Convolutional bias.
    bn_rm (torch.Tensor): BatchNorm running mean.
    bn_rv (torch.Tensor): BatchNorm running variance.
    bn_eps (float): BatchNorm epsilon.
    bn_w (Optional[torch.Tensor]): BatchNorm weight.
    bn_b (Optional[torch.Tensor]): BatchNorm bias.
    transpose (bool, optional): If True, transpose the conv weight. Defaults to False.

Returns:
    Tuple[torch.nn.Parameter, torch.nn.Parameter]: Fused convolutional weight and bias.
dtype)r2   torch
zeros_like	ones_likersqrtlenshapereshapetonn	Parameterrequires_grad)r%   r'   r)   r*   r+   r-   r.   r   conv_weight_dtypeconv_bias_dtypebn_var_rsqrtr9   fused_conv_wfused_conv_bs   &&&&&&&&      r   r   r   :   sI   2 &,&8fll>OO~!!%(|u%|&;;u~.LB1#V\\!2Q!677Q1#V\\!2Q!677\1::5AAEE F L ^|3d:TAEE F L
 	<)=)=><)=)=> r   c               $    V ^8  d   QhRRRRRR/# )r	   linearr   r   r   r   r   )r   s   "r   r   r   o   s&     0 00-0 0r   c           	     J   V P                   '       g   VP                   '       d   \        R4      h\        P                  ! V 4      p V P                  VP
                  8w  d7   VP
                  ^8w  d&   \        RV P                   RVP
                   24      hVP                  e   VP                  f   \        R4      h\        VP                  VP                  VP                  VP                  VP                  VP                  VP                  4      w  Vn	        Vn
        V# )as  Fuse a linear module and a BatchNorm module into a single, new linear module.

Args:
    linear (torch.nn.Linear): A Linear module.
    bn (torch.nn.modules.batchnorm._BatchNorm): A BatchNorm module.

Returns:
    torch.nn.Linear: The fused linear module.

.. note::
    Both ``linear`` and ``bn`` must be in eval mode, and ``bn`` must have its running buffers computed.
r   zaTo fuse, linear.out_features == bn.num_features or bn.num_features == 1, got linear.out_features=z and bn.num_features=r   )r   r   r   r   out_featuresnum_featuresr   r   fuse_linear_bn_weightsr   r    r!   )rE   r   fused_linears   && r   fuse_linear_bn_evalrK   o   s      "+++455==(L	 boo-"//Q2F''-':':&;;PQSQ`Q`Pac
 	

 
".."8RSS-C



		
.*L* r   c               8    V ^8  d   QhRRRRRRRRRRR	RR
RRR/# )r	   linear_wr&   linear_br(   r)   r*   r+   r,   r-   r.   r   r/   r   )r   s   "r   r   r      sX     " ""!" " 	"
 " " " 3"r   c                   V P                   pVe   VP                   MTpVf   \        P                  ! V4      pV\        P                  ! W4,           4      ,          p	W	P	                  R4      P                  VR7      ,          p
W,
          V	,          V,           P                  VR7      p\        P                  P                  WP                  4      \        P                  P                  WP                  4      3# )a  Fuse linear module parameters and BatchNorm module parameters into new linear module parameters.

Args:
    linear_w (torch.Tensor): Linear weight.
    linear_b (Optional[torch.Tensor]): Linear bias.
    bn_rm (torch.Tensor): BatchNorm running mean.
    bn_rv (torch.Tensor): BatchNorm running variance.
    bn_eps (float): BatchNorm epsilon.
    bn_w (torch.Tensor): BatchNorm weight.
    bn_b (torch.Tensor): BatchNorm bias.

Returns:
    Tuple[torch.nn.Parameter, torch.nn.Parameter]: Fused linear weight and bias.
r1   r3   )	r2   r4   r5   r7   	unsqueezer;   r<   r=   r>   )rM   rN   r)   r*   r+   r-   r.   linear_weight_dtypelinear_bias_dtypebn_scalefused_wfused_bs   &&&&&&&     r   rI   rI      s    . #..*2*>DW##E*ekk%.11H++B/229L2MMG H,t377>O7PG88g'='=>@R@R''A  r   )r#   r   rK   rI   )F)
__future__r   r   typingr   r4   __all__r   r   r#   r   rK   rI   r   r   r   <module>rY      sK    "    	>?
)#4
5#L2j0f"r   