
    3j                        S SK Jr  S SKrS SKJr  S SKJrJr  S\R                  S\\\R                  4   S\R                  S\\\R                  4   S	\\\R                  4   S
\R                  4S jr	 " S S\R                  5      rg)    )UnionN)nn)KORNIA_CHECKKORNIA_CHECK_IS_TENSORsrc1alphasrc2betagammareturnc                 H   [        U 5        [        U5        [        U R                  UR                  :H  SU R                   SUR                   35        [        U[        R
                  5      (       a$  [        U R                  UR                  :H  S5        O)[        R                  " XR                  U R                  S9n[        U[        R
                  5      (       a$  [        U R                  UR                  :H  S5        O)[        R                  " X0R                  U R                  S9n[        U[        R
                  5      (       a$  [        U R                  UR                  :H  S5        O)[        R                  " X@R                  U R                  S9nX-  X#-  -   U-   $ )a  Calculate the weighted sum of two Tensors.

.. image:: _static/img/add_weighted.png

The function calculates the weighted sum of two Tensors as follows:

.. math::
    out = src1 * alpha + src2 * beta + gamma

Args:
    src1: torch.Tensor with an arbitrary shape, equal to shape of src2.
    alpha: weight of the src1 elements as Union[float, torch.Tensor].
    src2: torch.Tensor with an arbitrary shape, equal to shape of src1.
    beta: weight of the src2 elements as Union[float, torch.Tensor].
    gamma: scalar added to each sum as Union[float, torch.Tensor].

Returns:
    Weighted torch.Tensor with shape equal to src1 and src2 shapes.

Example:
    >>> input1 = torch.rand(1, 1, 5, 5)
    >>> input2 = torch.rand(1, 1, 5, 5)
    >>> output = add_weighted(input1, 0.5, input2, 0.5, 1.0)
    >>> output.shape
    torch.Size([1, 1, 5, 5])

Notes:
    torch.Tensor alpha/beta/gamma have to be with shape broadcastable to src1 and src2 shapes.

z)src1 and src2 have different shapes. Got z and z%alpha has a different shape than src.)dtypedevicez$beta has a different shape than src.z%gamma has a different shape than src.)	r   r   shape
isinstancetorchTensortensorr   r   )r   r   r	   r
   r   s        M/home/wildlama/miniconda3/lib/python3.13/site-packages/kornia/enhance/core.pyadd_weightedr      s"   J 4 4 tzz)-VW[WaWaVbbghlhrhrgs+tu%&&TZZ5;;.0WXU**T[[I$%%TZZ4::-/UV||D

4;;G%&&TZZ5;;.0WXU**T[[I<$+%--    c                      ^  \ rS rSrSrS\\\R                  4   S\\\R                  4   S\\\R                  4   SS4U 4S jjr	S	\R                  S
\R                  S\R                  4S jr
SrU =r$ )AddWeightedU   a  Calculate the weighted sum of two Tensors.

The function calculates the weighted sum of two Tensors as follows:

.. math::
    out = src1 * alpha + src2 * beta + gamma

Args:
    alpha: weight of the src1 elements as Union[float, torch.Tensor].
    beta: weight of the src2 elements as Union[float, torch.Tensor].
    gamma: scalar added to each sum as Union[float, torch.Tensor].

Shape:
    - Input1: torch.Tensor with an arbitrary shape, equal to shape of Input2.
    - Input2: torch.Tensor with an arbitrary shape, equal to shape of Input1.
    - Output: Weighted torch.Tensor with shape equal to src1 and src2 shapes.

Example:
    >>> input1 = torch.rand(1, 1, 5, 5)
    >>> input2 = torch.rand(1, 1, 5, 5)
    >>> output = AddWeighted(0.5, 0.5, 1.0)(input1, input2)
    >>> output.shape
    torch.Size([1, 1, 5, 5])

Notes:
    torch.Tensor alpha/beta/gamma have to be with shape broadcastable to src1 and src2 shapes.

r   r
   r   r   Nc                 F   > [         TU ]  5         Xl        X l        X0l        g N)super__init__r   r
   r   )selfr   r
   r   	__class__s       r   r   AddWeighted.__init__s   s     	
	
r   r   r	   c                 X    [        XR                  X R                  U R                  5      $ r   )r   r   r
   r   )r   r   r	   s      r   forwardAddWeighted.forward{   s    D**dIItzzJJr   )r   r
   r   )__name__
__module____qualname____firstlineno____doc__r   floatr   r   r   r#   __static_attributes____classcell__)r    s   @r   r   r   U   s    :5%,,./7<UELL=P7QZ_`eglgsgs`sZt	KELL K K K Kr   r   )typingr   r   r   kornia.core.checkr   r   r   r*   r   Moduler    r   r   <module>r1      s   $    B8.
,,8.$%8. ,,8. u||#
$	8.
 $%8. \\8.v'K")) 'Kr   