
      i                     h    d dl Z d dlmZ d dlmZmZ d dlZd dlZd dl	m
Z d dlmZ  G d dee      Z
y)    N)Mapping)AnyUnion)SpikeDetection)Callbackc                       e Zd Z ej                         dddddeej                  eeej                  f   f   de	de
dd	fd
       Zy	)r   trainerz
pl.Trainer	pl_modulezpl.LightningModuleoutputsbatch	batch_idxreturnNc                    t        |t        j                        r|j                         }nEt        |t              r|d   j                         }n!t        dt        |      j                         | j                  /t        j                  j                  |j                  d      | _        t        j                  | ||||      S )Nlossz8outputs have to be of type torch.Tensor or Mapping, got zskip_batches.json)
isinstancetorchTensordetachr   	TypeErrortype__qualname__exclude_batches_pathospathjoindefault_root_dirFabricSpikeDetectionon_train_batch_end)selfr	   r
   r   r   r   r   s          v/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/pytorch_lightning/callbacks/spike.pyr   z!SpikeDetection.on_train_batch_end   s     gu||,>>#D)6?))+DVW[\cWdWqWqVrstt$$,(*W5M5MOb(cD%#66tWdES\]]    )__name__
__module__r   r   no_gradr   r   r   strr   intr    r!   r    r   r      sz    U]]_^^ (^ u||WS%,,->%??@	^
 ^ ^ 
^ ^r!   r   )r   collections.abcr   typingr   r   r   pytorch_lightningpl lightning_fabric.utilities.spiker   r   $pytorch_lightning.callbacks.callbackr   r'   r!   r    <module>r.      s+    	 #    S 9^)8 ^r!   