
    bIg
                    :    d dl mZ d dlZd dlmZ  G d de      Zy)    )annotationsN)OpRunc                  .    e Zd Zd ZddZ	 	 	 	 d	 ddZy)Ifc                    t        j                  | ||       d| j                  vrt        d      d|vrt        d      d| j                  vrt        d      y )Nopsetsz&run_params must contains key 'opsets'.verbosez'run_params must contains key 'verbose'.existing_functionsz2run_params must contains key 'existing_functions'.)r   __init__
run_paramsKeyError)self	onnx_noder   s      U/var/www/html/answerous/venv/lib/python3.12/site-packages/onnx/reference/ops/op_if.pyr   zIf.__init__   s[    tY
34??*CDDJ&DEEt6OPP 7    c                     y)zTells the runtime if this node needs the context
        (all the results produced so far) as it may silently access
        one of them (operator Loop).
        The default answer is `False`.
        T )r   s    r   need_contextzIf.need_context   s     r   Nc                `   |j                   dk7  r/t        d| j                  j                  dt	        |       d      |j                  d      }|rD| j                  d|       | j                  ||      }| j                  d       t        |      }d	}	nC| j                  d
|       | j                  ||      }| j                  d       t        |      }d}	|s#t        d| j                  j                  d      t        |      D ]  \  }
}|	|	d	k(  r| j                  n| j                  }|j                  }|j                  j                   j"                  D 
cg c]  }
|
j                   }}
t        d
d|	d||
   dt%        |       d| d       | j'                  |      S c c}
w )N   zOperator If (zC) expects a single element as condition, but the size of 'cond' is .r   z  -- then> {%r})
attributesz
  -- then<thenz  -- else> {%r}z
  -- else<elsez) does not have any output.zOutput z	 (branch=z, name=z) is None, available inputs=z, initializers=)size
ValueErrorr   namelenitem_log_run_then_branchtuple_run_else_branchRuntimeError	enumeratethen_branchelse_branchoutput_namesobjgraphinitializersorted_check_and_fix_outputs)r   condcontextr'   r&   r   cond_outputsfinalbranchifbrnamesinitss                  r   _runzIf._run   s    99> 3 366yz}  C  {D  zE  EF  G  		!II'1++G
+KGIIl#'NEFII'1++G
+KGIIl#'NEF 3 366QR  e$ 	DAqy)/6)9T%%t?O?O)+)A)ABABB"aU)F:WU1XL I((.w'8waQ 	 **511 Cs   F+)returnbool)NNNN)r.   znp.ndarray | np.bool_)__name__
__module____qualname__r   r   r9   r   r   r   r   r      s(    Q '2#'2r   r   )
__future__r   numpynponnx.reference.op_runr   r   r   r   r   <module>rC      s   
 #  '92 92r   