+
    ùäûj¨  ã                   óp   € ^ RI 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 R]
4      tR# )	é    )ÚAnyÚDictÚOptionalÚTupleN)Úrandom_generator)ÚIntensityAugmentationBase2D)Ú_clamp_unit_rangeÚ_to_device_nonblocking)Úadjust_gammac                   ó`   a a€ ] tR t^t oRtRtRV3R lV 3R llltR	V3R lR lltRtVt	V ;t
# )
ÚRandomGammaa
  Apply a random gamma power law to unit-range images.

``output = RandomGamma(gamma, gain)(input)`` raises pixels in selected images to a sampled gamma and multiplies
them by sampled gain.

The formula is torchvision's ``adjust_gamma`` for a float image: ``clamp(gain * input ** gamma, 0, 1)``.

.. image:: _static/img/RandomGamma.png

See the Convention block on :class:`~kornia.augmentation.IntensityAugmentationBase2D`.

Args:
    p: probability of applying the transformation.
    gamma: the gamma factor to apply.
    gain: the gain factor to apply.
    same_on_batch: apply the same transformation across the batch.
    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)``, Optional: ``(B, 3, 3)``
    - Output: ``(B, C, H, W)``

Convention:
    - input values are clamped into ``[0, 1]`` before the operation, and the result is clamped
      into the same range. This applies only to samples selected by the probability gate.
    - the clamp is not optional: unlike :class:`RandomBrightness` and :class:`RandomContrast` this class has
      no ``clip_output``.
    - ``gamma`` and ``gain`` must be non-negative. Neither is checked at construction: the check is in
      :func:`kornia.enhance.adjust_gamma`, so a negative value raises a ``RuntimeError`` on the forward pass.
      It is not run for an MPS image, where a negative value goes through the same formula unchecked.

.. note::
    This function internally uses :func:`kornia.enhance.adjust_gamma`

See Also:
    - :class:`RandomBrightness`: applies an additive linear adjustment.
    - :class:`RandomContrast`: applies a multiplicative linear adjustment.

Examples:
    >>> rng = torch.manual_seed(0)
    >>> inputs = torch.rand(1, 3, 3, 3)
    >>> aug = RandomGamma((0.5,2.),(1.5,1.5),p=1.)
    >>> aug(inputs)
    tensor([[[[1.0000, 1.0000, 0.3912],
              [0.4883, 0.7801, 1.0000],
              [1.0000, 1.0000, 0.9702]],
    <BLANKLINE>
             [[1.0000, 0.8368, 0.9048],
              [0.1824, 0.5597, 0.7609],
              [1.0000, 1.0000, 1.0000]],
    <BLANKLINE>
             [[0.5452, 0.7441, 1.0000],
              [1.0000, 0.8990, 1.0000],
              [0.9267, 1.0000, 1.0000]]]])

To apply the exact augmenation again, you may take the advantage of the previous parameter state:
    >>> input = torch.rand(1, 3, 32, 32)
    >>> aug = RandomGamma((0.8,1.2), p=1.)
    >>> (aug(input) == aug(input, params=aug._params)).all()
    tensor(True)

Tc                óh   <€ V ^8„  d   QhRS[ S[S[3,          RS[ S[S[3,          RS[RS[RS[RR/# )é   ÚgammaÚgainÚsame_on_batchÚpÚkeepdimÚreturnN)r   ÚfloatÚbool)ÚformatÚ__classdict__s   "€ÚcC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\augmentation\_2d\intensity\gamma.pyÚ__annotate__ÚRandomGamma.__annotate__^   sY   ø€ ÷ 
ñ 
á‘U™E�\Õ"ð
ñ ‘E™5�LÕ!ð
ñ ð	
ñ
 ð
ñ ð
ð 
ñ
ó    c                ór   <€ \         SV `  WCVR 7       \        P                  ! VRRR3VRRR34      V n        R# ))r   r   r   Úgamma_factorNÚgain_factor)ÚsuperÚ__init__ÚrgÚPlainUniformGeneratorÚ_param_generator)Úselfr   r   r   r   r   Ú	__class__s   &&&&&&€r   r"   ÚRandomGamma.__init__^   sA   ø€ ô 	‰Ñ˜1À7ÐÔKÜ "× 8Ò 8Ø�N D¨$Ð/°$¸ÀtÈTÐ1Ró!
ˆÖr   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   ÚinputÚparamsÚflagsÚ	transformr   )ÚtorchÚTensorr   Ústrr   r   )r   r   s   "€r   r   r   k   sd   ø€ ÷ 
>ñ 
>á�|‰|ð
>ñ ‘S™%Ÿ,™,Ð&Õ'ð
>ñ ‘C™�H�~ð	
>ñ
 ™EŸL™LÕ)ð
>ñ 
�‰ñ
>r   c                óÐ   € \        V4      p\        VR ,          VP                  VP                  4      p\        VR,          VP                  VP                  4      p\	        WV4      # )r   r    )r	   r
   ÚdeviceÚdtyper   )r&   r*   r+   r,   r-   r   r    s   &&&&&  r   Úapply_transformÚRandomGamma.apply_transformk   sW   € ô " %Ó(ˆÜ-¨f°^Õ.DÀeÇlÁlÐTY×T_ÑT_Ó`ˆÜ,¨V°MÕ-BÀEÇLÁLÐRW×R]ÑR]Ó^ˆÜ˜E°Ó=Ð=r   )r%   )©ç      ð?r7   r6   Fr7   F)N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__ÚSUBSTITUTE_SKIPPED_SAMPLESr"   r4   Ú__static_attributes__Ú__classdictcell__Ú__classcell__)r'   r   s   @@r   r   r      s,   ù‡ € ñ=ð~ "&Ð÷
õ 
÷
>÷ 
>ò 
>r   r   )Útypingr   r   r   r   r.   Úkornia.augmentationr   r#   Ú&kornia.augmentation._2d.intensity.baser   Úkornia.core.utilsr	   r
   Úkornia.enhance.adjustr   r   © r   r   Ú<module>rG      s+   ð÷$ .Ó -ã å 6Ý Nß GÝ .ôY>Ð-ö Y>r   