+
    öäûjX  ã                   ó„   € ^ RI HtHtHtHtHt ^ RIt^ RIHt	 ^ RI
Ht ^ RIHtHt ^ RIHt ^ RIHtHt  ! R R	]4      tR# )
é    )ÚAnyÚDictÚOptionalÚTupleÚUnionN)Úrandom_generator)ÚGeometricAugmentationBase2D)ÚResampleÚSamplePadding)Ú_as_tensor_nonblocking)Úget_translation_matrix2dÚwarp_affinec                   óä   a a€ ] tR t^t oRtRR]P                  P                  RR]P                  P                  RR3V3R lV 3R lllt
V3R lR ltRV3R	 lR
 lltRV3R lR lltRtVtV ;t# )ÚRandomTranslateaB  Translate images by a random 2D shift, applied per sample with probability ``p`` (default 0.5).

``output = RandomTranslate(translate_x, translate_y, ...)(input)`` shifts selected images of shape
``(B, C, H, W)``.

Args:
    translate_x: tuple of maximum absolute fraction for horizontal translations.
        For example translate_x=(a, b), then horizontal shift
        is randomly sampled in the range img_width * a < dx < img_width * b
    translate_y: tuple of maximum absolute fraction for vertical translations.
        For example translate_y=(a, b), then vertical shift
        is randomly sampled in the range img_height * a < dy < img_height * b.
    resample: resample mode from "nearest" (0) or "bilinear" (1).
    padding_mode: padding mode from "torch.zeros" (0), "border" (1) or "reflection" (2).
    same_on_batch: apply the same transformation across the batch.
    align_corners: interpolation flag.
    p: probability of applying the transformation to each sample.
    keepdim: whether to keep the output shape the same as input (True) or broadcast it to the batch form (False).

Shape:
    - Input: ``(C, H, W)`` or ``(B, C, H, W)``
    - Output: ``(B, C, H, W)``

Convention:
    - See :class:`~kornia.augmentation.GeometricAugmentationBase2D` for coordinates, defaults and inverse.
    - ``translate_x`` and ``translate_y`` are independently sampled fractions of ``W`` and ``H``; positive
      values move content right and down. Omitting either range fixes that axis at zero.

.. note::
    This function internally uses :func:`kornia.geometry.transform.warp_affine`.

.. note::
    Unlike torchvision's ``RandomAffine(degrees=0, translate=...)``, which translates every image, this class
    translates each sample with probability ``p``, 0.5 by default; with ``same_on_batch=True`` one draw decides for
    the whole batch. Pass ``p=1.0`` to translate every sample.

See Also:
    - :class:`RandomAffine`: samples a combined affine transformation.

Examples:
    >>> import torch
    >>> rng = torch.manual_seed(0)
    >>> input = torch.rand(1, 1, 3, 3)
    >>> aug = RandomTranslate((-0.2, 0.2), (-0.1, 0.1), p=1.)
    >>> out = aug(input)
    >>> out, aug.transform_matrix
    (tensor([[[[0.3897, 0.6847, 0.2314],
              [0.1384, 0.3297, 0.5771],
              [0.3749, 0.7565, 0.4780]]]]), tensor([[[ 1.0000,  0.0000,  0.1588],
             [ 0.0000,  1.0000, -0.0907],
             [ 0.0000,  0.0000,  1.0000]]]))
    >>> aug.inverse(out)
    tensor([[[[0.3969, 0.5571, 0.1770],
              [0.1930, 0.3910, 0.4591],
              [0.4113, 0.6812, 0.4096]]]])

To apply the exact augmenation again, you may take the advantage of the previous parameter state:
    >>> input = torch.randn(1, 3, 32, 32)
    >>> aug = RandomTranslate((-0.2, 0.2), (-0.1, 0.1), p=1.)
    >>> (aug(input) == aug(input, params=aug._params)).all()
    tensor(True)

NFg      à?c                ó"  <€ V ^8„  d   QhRS[ S[S[P                  S[S[S[3,          3,          ,          RS[ S[S[P                  S[S[S[3,          3,          ,          RS[S[S[S[3,          RS[	RS[	RS[S[S[S[
3,          RS[RS[	R	R
/	# )é   Útranslate_xÚtranslate_yÚresampleÚsame_on_batchÚalign_cornersÚpadding_modeÚpÚkeepdimÚreturnN)r   r   ÚtorchÚTensorr   ÚfloatÚstrÚintr
   Úboolr   )ÚformatÚ__classdict__s   "€ÚgC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\augmentation\_2d\geometric\translate.pyÚ__annotate__ÚRandomTranslate.__annotate__^   sµ   ø€ ÷ 
ñ 
á™e¡E§L¡L±%¹¹u¸Õ2EÐ$EÕFÕGð
ñ ™e¡E§L¡L±%¹¹u¸Õ2EÐ$EÕFÕGð
ñ ™™S¡(Ð*Õ+ð	
ñ
 ð
ñ ð
ñ ™C¡¡mÐ3Õ4ð
ñ ð
ñ ð
ð 
ñ
ó    c	                óÊ   <€ \         S	V `  WtVR 7       \        P                  ! W4      V n        R\
        P                  ! V4      R\        P                  ! V4      RV/V n        R# ))r   r   r   r   r   r   N)	ÚsuperÚ__init__ÚrgÚTranslateGeneratorÚ_param_generatorr
   Úgetr   Úflags)
Úselfr   r   r   r   r   r   r   r   Ú	__class__s
   &&&&&&&&&€r$   r*   ÚRandomTranslate.__init__^   sV   ø€ ô 	‰Ñ˜1À7ÐÔKÜ79×7LÒ7LÈ[Ó7fˆÔàœŸš XÓ.ØœM×-Ò-¨lÓ;Ø˜]ð
ˆŽ
r'   c                óš   <€ V ^8„  d   QhRS[ P                  RS[S[S[ P                  3,          RS[S[S[3,          RS[ P                  /# )r   ÚinputÚparamsr/   r   )r   r   r   r   r   )r"   r#   s   "€r$   r%   r&   q   sT   ø€ ÷ iñ iÙ—\‘\ðiÙ+/±±U·\±\Ð0AÕ+BðiÙKOÑPSÑUXÐPXÍ>ðiá	�‰ñir'   c                ó^  € VR ,          VR,          rTVP                   VP                   8w  dA   \        WAP                   VP                  4      p\        WQP                   VP                  4      p\        P                  ! WE.RR7      p\        \        WaP                   VP                  4      4      # )r   r   )Údiméÿÿÿÿ)Údevicer   Údtyper   Ústackr   )r0   r4   r5   r/   r   r   Útranslationss   &&&&   r$   Úcompute_transformationÚ&RandomTranslate.compute_transformationq   s„   € ð $*¨-Õ#8¸&ÀÕ:O�[Ø×Ñ ×!3Ñ!3Ô3ô 1°¿l¹lÈEÏKÉKÓXˆKÜ0°¿l¹lÈEÏKÉKÓXˆKÜ—{’{ KÐ#=À2ÔFˆÜ'Ô(>¸|Ï\É\Ð[`×[fÑ[fÓ(gÓhÐhr'   c          
      óÄ   <€ V ^8„  d   QhRS[ P                  RS[S[S[ P                  3,          RS[S[S[3,          RS[S[ P                  ,          RS[ P                  /# )r   r4   r5   r/   Ú	transformr   )r   r   r   r   r   r   )r"   r#   s   "€r$   r%   r&   ~   sd   ø€ ÷ 
ñ 
á�|‰|ð
ñ ‘S™%Ÿ,™,Ð&Õ'ð
ñ ‘C™�H�~ð	
ñ
 ™EŸL™LÕ)ð
ñ 
�‰ñ
r'   c           	     óN  € VP                   w   rVp\        V\        P                  4      '       g   \	        R \        V4       R24      h\        VVR,          Wg3VR,          P                  P                  4       VR,          VR,          P                  P                  4       R7      # )ú0Expected the `transform` be a torch.Tensor. Got Ú.r   r   r   )r   r   )ºNNN:Nr   NrD   )	ÚshapeÚ
isinstancer   r   Ú	TypeErrorÚtyper   ÚnameÚlower)r0   r4   r5   r/   r@   Ú_ÚheightÚwidths   &&&&&   r$   Úapply_transformÚRandomTranslate.apply_transform~   s”   € ð $Ÿk™kÑˆˆ1�eÜ˜)¤U§\¡\×2Ò2ÜÐNÌtÐT]ËÐN_Ð_`ÐaÓbÐbäØØ�hÕØˆOØ�*Õ×"Ñ"×(Ñ(Ó*Ø Õ0Ø˜~Õ.×3Ñ3×9Ñ9Ó;ô
ð 	
r'   c                óÀ   <€ V ^8„  d   QhRS[ P                  RS[S[S[3,          RS[S[ P                  ,          RS[S[S[S[3,          ,          RS[ P                  /# )r   r4   r/   r@   Úsizer   )r   r   r   r   r   r   r   r    )r"   r#   s   "€r$   r%   r&   ’   sc   ø€ ÷ 
ñ 
á�|‰|ð
ñ ‘C™�H�~ð
ñ ™EŸL™LÕ)ð	
ñ
 ‘u™S¡#˜X•Õ'ð
ñ 
�‰ñ
r'   c           
     ó  € \        V\        P                  4      '       g   \        R \	        V4       R24      hV P                  VV P                  \        P                  ! W1P                  VP                  R7      VR7      # )rB   rC   )r9   r:   )r5   r@   r/   )
rF   r   r   rG   rH   rN   Ú_paramsÚ	as_tensorr9   r:   )r0   r4   r/   r@   rQ   s   &&&&&r$   Úinverse_transformÚ!RandomTranslate.inverse_transform’   sl   € ô ˜)¤U§\¡\×2Ò2ÜÐNÌtÐT]ËÐN_Ð_`ÐaÓbÐbØ×#Ñ#ØØ—<‘<Ü—o’o i¿¹ÈEÏKÉKÔXØð	 $ó 
ð 	
r'   )r-   r/   )N)NN)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r
   ÚBILINEARrI   r   ÚZEROSr*   r=   rN   rU   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r1   r#   s   @@r$   r   r      sn   ù‡ € ñ>ðD KOØJNØ.6×.?Ñ.?×.DÑ.DØ#Ø#Ø7D×7JÑ7J×7OÑ7OØØ÷
õ 
÷&ið i÷
ò 
÷(
÷ 
ò 
r'   r   )Útypingr   r   r   r   r   r   Úkornia.augmentationr   r+   Ú&kornia.augmentation._2d.geometric.baser	   Úkornia.constantsr
   r   Úkornia.core.utilsr   Úkornia.geometry.transformr   r   r   © r'   r$   Ú<module>rh      s.   ð÷$ 5Õ 4ã å 6Ý Nß 4Ý 4ß KôC
Ð1ö C
r'   