
    Si7j                       S SK Jr  S SKJr  S SKJrJrJrJrJ	r	J
r
Jr  \(       a  S SKJr   S       SS jjr      S                   SS jjr          S                           SS jjr        S                     SS	 jjr        S                     SS
 jjr S       SS jjr S       SS jjrg)    )annotations)TYPE_CHECKING)AttributeProto
GraphProto
ModelProtoTensorProtocheckerhelperutils)MutableMappingNc                   [        U [        5      (       d  [        S5      e[        U[        5      (       d  [        S5      eSS jnSSS jjn/ nU(       d  / nU Vs1 s H  ofS   iM	     nnU" U" U 5      U" XS95      nU(       a  UR                  SU45        U" U R                   V	s/ s H  oR
                  PM     sn	UR                   V	s/ s H  oR
                  PM     sn	5      nU(       a  UR                  SU45        U" U R                   V	s/ s H  oR
                  PM     sn	UR                   V	s/ s H  oR
                  PM     sn	5      nU(       a  UR                  S	U45        U" U R                   V	s/ s H  oR                  R
                  PM     sn	UR                   V	s/ s H  oR                  R
                  PM     sn	5      U" U R                   V	s/ s H  oR                  R
                  PM     sn	UR                   V	s/ s H  oR                  R
                  PM     sn	5      -   nU(       a  UR                  S
U45        U$ s  snf s  sn	f s  sn	f s  sn	f s  sn	f s  sn	f s  sn	f s  sn	f s  sn	f )a  Checks whether there are name collisions between two graphs

Returns a list of tuples where the first element represents the member containing overlapping names
(One of: "node", "edge", "value_info", "initializer", "sparse_initializer"), and the
second element contains a list of names that appear in both graphs on that category.

Optionally, it takes an io_map, representing the output/inputs to be connected. It provided, overlapping
present in the io_map argument will be ignored.
 g1 argument is not an ONNX graph g2 argument is not an ONNX graphc                B    [        [        U 5      [        U5      -  5      $ N)listset)c1c2s     K/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/onnx/compose.py_overlapping-check_overlapping_names.<locals>._overlapping'   s    CGc"g%&&    c                   Uc
  [        5       n/ nU R                   Hi  nUR                   H#  nUS:w  d  M  XA;  d  M  UR                  U5        M%     UR                   H#  nUS:w  d  M  XQ;  d  M  UR                  U5        M%     Mk     U$ )N )r   nodeinputappendoutput)graphexcludeedgesnios         r   _edge_names,check_overlapping_names.<locals>._edge_names*   st    ?eGAWW7q/LLO  XX7q/LLO 	  r      )r!   edge
value_infoinitializersparse_initializer)r   	list[str]r   r-   returnr-   r   )r    r   r!   zset[str] | Noner.   r-   )

isinstancer   	TypeErrorr   r*   namer+   r,   valuesindices)
g1g2io_mapr   r&   resultelemio_map_inputsoverlapes
             r   check_overlapping_namesr<      s    b*%%:;;b*%%:;;' F)/0!WM0 ;r?K,RSGvw'('A'"--)H-Q&&-)HG |W-.(A(2>>*J>a66>*JG }g./ " 5 56 51 56 " 5 56 51 56 	!#!6!67!6A!67!#!6!67!6A!67	G +W56M; 1 	()H 	)*J 	7677s6   I)II 
I%9I*
?I/.I4
#I9
I>c	                B  ^(^) [        U [        5      (       d  [        S5      e[        U[        5      (       d  [        S5      eU(       d  U(       a  U(       a&  [        5       n	U	R                  U 5        U	n [	        XS9n U(       a&  [        5       n
U
R                  U5        U
n[	        XS9nU Vs/ s H)  nU(       a  X[S   -   OUS   U(       a  XkS   -   OUS   4PM+     nnU Vs1 s H  oS   iM	     nnU Vs1 s H  oS   iM	     nnU VVs0 s H  u  pX_M	     snnm)U R
                   Vs1 s H  nUR                  iM     nnUR                   Vs1 s H  nUR                  iM     nnU(       d  U(       Ga  U(       dM  U R                   Vs/ s H  nUR                  PM     nnUR                   Vs/ s H  nUR                  PM     nnO[        U5      nU R                   Vs/ s H!  nUR                  U;   d  M  UR                  PM#     nnUR                   Vs/ s H1  nUR                  U;   d  UR                  U;   d  M%  UR                  PM3     nnU(       dM  U R
                   Vs/ s H  nUR                  PM     nnUR
                   Vs/ s H  nUR                  PM     nnO[        U5      nU R
                   Vs/ s H1  nUR                  U;   d  UR                  U;   d  M%  UR                  PM3     nnUR
                   Vs/ s H!  nUR                  U;   d  M  UR                  PM#     nn[        U5      [        U R                  5      :  d"  [        U5      [        U R
                  5      :  aF  [        R                  " [        R                  " U 5      5      nUR                  UU5      R                  n [        U5      [        UR                  5      :  d"  [        U5      [        UR
                  5      :  aF  [        R                  " [        R                  " U5      5      nUR                  UU5      R                  nU H0  u  nnUU;  a  [!        SU S35      eUU;  d  M#  [!        SU S	35      e   [#        XU5      n[        U5      S:  a/  US   u  nn [!        S
U S3SR%                  U 5      -   S-   S-   5      e[        5       n!U!R&                  R)                  U R&                  5        [        U!R&                  5      n"U!R&                  R)                  UR&                  5        [        U!R&                  5      n#SU(U)4S jjm(T(" U!U"U#5        U(       a  [        U5      nU!R                  R)                  U R                   Vs/ s H  nUR                  U;   d  M  UPM     sn5        U!R                  R)                  UR                   Vs/ s H  nUR                  U;   d  M  UPM     sn5        OmU!R                  R)                  U R                  5        U!R                  R)                  UR                   Vs/ s H  nUR                  U;  d  M  UPM     sn5        U(       a  [        U5      nU!R
                  R)                  U R
                   Vs/ s H  nUR                  U;   d  M  UPM     sn5        U!R
                  R)                  UR
                   Vs/ s H  nUR                  U;   d  M  UPM     sn5        OmU!R
                  R)                  U R
                   Vs/ s H  nUR                  U;  d  M  UPM     sn5        U!R
                  R)                  UR
                  5        U!R*                  R)                  U R*                  5        U!R*                  R)                  UR*                   V$s/ s H  n$U$R                  U;  d  M  U$PM     sn$5        U!R,                  R)                  U R,                  5        U!R,                  R)                  UR,                   V$s/ s H!  n$U$R.                  R                  U;  d  M  U$PM#     sn$5        U!R0                  R)                  U R0                  5        U!R0                  R)                  UR0                   V%s/ s H  n%U%R                  U;  d  M  U%PM     sn%5        U!R0                   V%s1 s H  n%U%R                  iM     n&n%U!R
                   Vs1 s H  nUR                  iM     n'nU!R0                  R)                  U R
                   Vs/ s H;  nUR                  U;   d  M  UR                  U&;  d  M'  UR                  U';  d  M9  UPM=     sn5        Ub  UO&SR%                  U R                  UR                  /5      U!l        UcZ  SU R                   SUR                   S3U R                  -   S-   U R2                  -   S-   UR                  -   S-   UR2                  -   nUU!l        U!$ s  snf s  snf s  snf s  snnf s  snf s  snf s  snf s  snf s  snf s  snf s  snf s  snf s  snf s  snf s  snf s  snf s  snf s  snf s  snf s  snf s  sn$f s  sn$f s  sn%f s  sn%f s  snf s  snf )a%  Combines two ONNX graphs into a single one.

The combined graph is defined by connecting the specified set of outputs/inputs. Those inputs/outputs
not specified in the io_map argument will remain as inputs/outputs of the combined graph.

Arguments:
    g1 (GraphProto): First graph
    g2 (GraphProto): Second graph
    io_map (list of pairs of string): The pairs of names [(out0, in0), (out1, in1), ...]
                                      representing outputs of the first graph and inputs of the second
                                      to be connected
    inputs (list of string): Optional list of inputs to be included in the combined graph
                             By default, all inputs not present in the ``io_map`` argument will be
                             included in the combined model
    outputs (list of string): Optional list of outputs to be included in the combined graph
                              By default, all outputs not present in the ``io_map`` argument will be
                              included in the combined model
    prefix1 (string): Optional prefix to be added to all names in g1
    prefix2 (string): Optional prefix to be added to all names in g2
    name (string): Optional name for the combined graph
                   By default, the name is g1.name and g2.name concatenated with an underscore delimiter
    doc_string (string): Optional docstring for the combined graph
                         If not provided, a default docstring with the concatenation of g1 and g2 docstrings is used

Returns:
    GraphProto
r   r   prefixr   r(   zOutput z is not present in g1zInput z is not present in g2z=Cant merge two graphs with overlapping names. Found repeated z names: , 
zYConsider using ``onnx.compose.add_prefix`` to add a prefix to names in one of the graphs.c           	       > [        X5       H  nU R                  U   nUR                   HT  nUR                  [        R
                  :X  d  M#  T" UR                  S[        UR                  R                  5      5        MV     [        UR                  5       H  u  pgUT	;   d  M  T	U   UR                  U'   M!     M     g Nr   )
ranger   	attributetyper   GRAPHglen	enumerater   )
	sub_graphstartendnode_idxr   attrindexname_
connect_ioreversed_io_maps
           r   rR    merge_graphs.<locals>.connect_io   s    e)H>>(+D99 4 44tvvq#dffkk*:; ' !*$** 5O+(7(>DJJu% !6 *r   _zGraph combining  and z

)rK   r   rL   intrM   rW   r.   None)r/   r   r0   CopyFromadd_prefix_graphr   r1   r   r   rI   r   	Extractorr
   
make_modelextract_modelr    
ValueErrorr<   joinr   extendr+   r,   r2   r*   
doc_string)*r4   r5   r6   inputsoutputsprefix1prefix2r1   ra   g1_copyg2_copyioio_map_g1_outsio_map_g2_insout_namein_namer%   g1_outsr$   g2_ins	g1_inputs	g2_inputs	input_set
g1_outputs
g2_outputs
output_sete1e2g1_out_name
g2_in_nameoverlapping_namescategorynamesrH   g2_nodes_beging2_nodes_endinitvivalue_info_namesoutput_namesrR   rS   s*                                           @@r   merge_graphsr   [   s   L b*%%:;;b*%%:;; ' lGR B!"5B lGR B!"5B 

  $+Q%1#*Q%1  	 
 '--fefN-%+,VrUVM,BHI&->Xw(&IO!yy)y!qvvyG) hh'haffhF' )+2AI2)+2AI2IFI)+IAQVVy5HII !A66Y&!&&M*A !   *,))4)Q!&&)J4*,))4)Q!&&)J4JWJ "A66Z'166^+C "  
 +-))L)Qqvv7K&!&&)JLy>CM)S_s299~-M!2!22!67B!!)Z8>>By>CM)S_s299~-M!2!22!67B!!)Z8>>B $*Zg%w{m3HIJJV#vj\1FGHH	 $* 0?
!+A.%&Zx1ii  j	j
 	
 	AFFMM"''[NFFMM"''qvv;L	? 	? q.,/K		288C8aqvv/B8CD	288C8aqvv/B8CD	rxx 	288K8aqvv]/J8KL\
	BIIFIq:1EIFG	BIIFIq:1EIFG	BIINIq~1MINO			"MM(MM..K.$DII],J.K  5 56 --	
-{{}4 -	
 LL&LLbmmTmrwwm7SmTU*+,,7,B,7$%HH-HqAFFHL-LL YY	
vv'  ..  l*	 	
 %T388RWWbgg4F+GAFrwwiuRWWIR8gg mm 	
 gg  mm 	 ALHi
 .,I)'
 32 J 54
 Mj DC L GFN
 	L
	
 U7-	
s   /0h%h#9h(h-.h3h8h=6i(i i $ii/ii$i/ii 'i i%+i%i*3i*	i/!i/#i4;i4+i9i94i>i>jj3jj*jjjj>jj(j:jc           
        [        U [        5      (       d  [        S5      e[        U[        5      (       d  [        S5      eU R                  UR                  :w  a&  [	        SU R                   SUR                   S35      eU R                  n0 n[        U R                  5      [        UR                  5      -   nU Hr  nUR                  U;   aF  UUR                     nUR                  U:w  a%  [	        SU R                   SUR                   35      eMY  UR                  UUR                  '   Mt     U(       d  U(       a  U(       a&  [        5       nUR                  U 5        Un [        XS9n U(       a&  [        5       nUR                  U5        Un[        XS9nU Vs/ s H+  nU(       a  UUS	   -   OUS	   U(       a  UUS
   -   OUS
   4PM-     nn[        U R                  UR                  UUUUUS9n[        R                  " UU	U
UUUUS9n0 nU R                   H  nUR                   UUR"                  '   M     UR                   Hv  nUR"                  U;   aJ  UUR"                     nUUR                   :w  a)  [	        SUR"                   SU SUR                    S35      eM]  UR                   UUR"                  '   Mx     [        R$                  " UU5        [        U R&                   Vs1 s H  nUR(                  iM     snUR&                   Vs1 s H  nUR(                  iM     sn-  5      nU(       a  [	        SSR+                  U5      -   5      eUR&                  R-                  U R&                  5        UR&                  R-                  UR&                  5        [.        R0                  " U5        U$ s  snf s  snf s  snf )a  Combines two ONNX models into a single one.

The combined model is defined by connecting the specified set of outputs/inputs.
Those inputs/outputs not specified in the io_map argument will remain as
inputs/outputs of the combined model.

Both models should have the same IR version, and same operator sets imported.

Arguments:
    m1 (ModelProto): First model
    m2 (ModelProto): Second model
    io_map (list of pairs of string): The pairs of names [(out0, in0), (out1, in1), ...]
                                      representing outputs of the first graph and inputs of the second
                                      to be connected
    inputs (list of string): Optional list of inputs to be included in the combined graph
                             By default, all inputs not present in the ``io_map`` argument will be
                             included in the combined model
    outputs (list of string): Optional list of outputs to be included in the combined graph
                              By default, all outputs not present in the ``io_map`` argument will be
                              included in the combined model
    prefix1 (string): Optional prefix to be added to all names in m1
    prefix2 (string): Optional prefix to be added to all names in m2
    name (string): Optional name for the combined graph
                   By default, the name is g1.name and g2.name concatenated with an underscore delimiter
    doc_string (string): Optional docstring for the combined graph
                         If not provided, a default docstring with the concatenation of g1 and g2 docstrings is used
    producer_name (string): Optional producer name for the combined model. Default: 'onnx.compose'
    producer_version (string): Optional producer version for the combined model. Default: "1.0"
    domain (string): Optional domain of the combined model. Default: ""
    model_version (int): Optional version of the graph encoded. Default: 1

Returns:
    ModelProto
z m1 argument is not an ONNX modelz m2 argument is not an ONNX modelzIR version mismatch z != z-. Both models should have the same IR versionzPCan't merge two models with different operator set ids for a given domain. Got: rV   r>   r   r(   )rb   rc   r1   ra   )producer_nameproducer_versiondomainmodel_versionopset_imports
ir_versionzaCan't merge models with different values for the same model metadata property. Found: property = z, with values .zPCan't merge models with overlapping local function names. Found in both graphs: r@   )r/   r   r0   r   r^   r   opset_importr   versionrY   
add_prefixr   r    r
   r\   metadata_propsvaluekeyset_model_props	functionsr1   r_   	MergeFromr	   check_model)m1m2r6   rb   rc   rd   re   r1   ra   r   r   r   r   r   opset_import_mapr   entryfound_versionm1_copym2_copyrh   r    modelmodel_props
meta_entryr   ffunction_overlaps                               r   merge_modelsr   )  s   b b*%%:;;b*%%:;;	}}%"2==/bmm_ E; ;
 	
 J13)D,AAM<<++,U\\:M}}- OO,E"//1BD  . .3]]U\\*  ' lGR BB/B lGR BB/B 

  $+"Q%1#*"Q%1  	 
 

E #)##E K''
&0&6&6JNN# (''
>>[(
/E
((( **4..)9weT^TdTdSeefh  ) +5*:*:K
' ( 5+. &A&",,)G,Q!&&,)GG &(,		2B(CD
 	
 
OObll+	OObll+Lq
Z 	')Gs   2N8-N=O
c
           	     L	   [        U [        5      (       d  [        S5      eU(       d  [        5       n
U
R                  U 5        OU n
SS jnU	c  0 n	U(       a\  U
R                   Vs1 s H  oR
                  iM     nnU
R                   H'  nUR                   H  nX;  d  M
  U" X5      X'   M     M)     U(       a3  U
R                   H#  nU" UUR
                  5      U	UR
                  '   M%     U(       a3  U
R                   H#  nU" UUR
                  5      U	UR
                  '   M%     U(       af  U
R                   HV  nU" XR
                  5      Ul        UR                   H,  nUR                  (       d  M  [        UR                  USU	S9  M.     MX     U(       a  U
R                   H#  nU" UUR
                  5      U	UR
                  '   M%     U
R                   Hk  nU" UUR                  R
                  5      U	UR                  R
                  '   U" UUR                  R
                  5      U	UR                  R
                  '   Mm     U(       a3  U
R                   H#  nU" UUR
                  5      U	UR
                  '   M%     U
R                   H  n[!        UR                  5       H-  u  nnUR                  U   U	;   d  M  U	U   UR                  U'   M/     [!        UR                  5       H-  u  nnUR                  U   U	;   d  M  U	U   UR                  U'   M/     M     U
R                   H)  nUR
                  U	;   d  M  U	UR
                     Ul        M+     U
R                   H)  nUR
                  U	;   d  M  U	UR
                     Ul        M+     U
R                   H)  nUR
                  U	;   d  M  U	UR
                     Ul        M+     U
R                   H  nUR                  R
                  U	;   a(  U	UR                  R
                     UR                  l        UR                  R
                  U	;   d  Ma  U	UR                  R
                     UR                  l        M     U
R                   H)  nUR
                  U	;   d  M  U	UR
                     Ul        M+     U
$ s  snf )a  Adds a prefix to names of elements in a graph: nodes, edges, inputs, outputs,
initializers, sparse initializer, value infos.

It can be used as a utility before merging graphs that have overlapping names.
Empty names are not prefixed.

Arguments:
    graph (GraphProto): Graph
    prefix (str): Prefix to be added to each name in the graph
    rename_nodes (bool): Whether to prefix node names
    rename_edges (bool): Whether to prefix node edge names
    rename_inputs (bool): Whether to prefix input names
    rename_outputs (bool): Whether to prefix output names
    rename_initializers (bool): Whether to prefix initializer and sparse initializer names
    rename_value_infos (bool): Whether to prefix value info names
    inplace (bool): If True, mutates the graph directly.
                    Otherwise, a copy will be created
    name_map: (Dict): shared name_map in subgraph

Returns:
    GraphProto
#graph argument is not an ONNX graphc                ,    [        U5      S:  a  X-   $ U$ rC   )rI   )r?   r1   s     r   	_prefixed#add_prefix_graph.<locals>._prefixed  s     #D	Av}747r   T)inplacename_map)r?   strr1   r   r.   r   )r/   r   r0   rY   r   r1   r   r   rE   rH   rZ   r+   r,   r2   r3   r*   rJ   )r    r?   rename_nodesrename_edgesrename_inputsrename_outputsrename_initializersrename_value_infosr   r   rH   r   r%   graph_output_namesr#   r;   r   rE   r~   sparse_initr$   r   input_in_descout_descr+   r,   r*   s                               r   rZ   rZ     s   D eZ((=>>L	

58  /0hh7hffh7AXX."+F"6HK  
 WWE#,VUZZ#@HUZZ  XXE#,VUZZ#@HUZZ   Avvv.AF[[	;;;$!VTH )  MMD"+FDII">HTYY "//K09**//1H['',,- 2;++002H[((--.	 0 \\E#,VUZZ#@HUZZ  " VV"188,IAvxx{h&&v. - #177+IAvwwqzX%%f-
 ,	  77<<8##GLL1GL  HH==H$$X]]3HM  }}x''(8(89K %  22$$))X5-56H6O6O6T6T-U%%*%%**h6.67I7Q7Q7V7V.W&&+	 3 ll
??h&&z7JO # HC 8s   %R!c
                Z   [        U [        5      (       d  [        S5      eU	(       d  [        5       n
U
R                  U 5        U
n [	        U R
                  UUUUUUUSS9	  U(       a  0 nU R                   H%  nXR                  -   nXUR                  '   Xl        M'     U R                   H;  nUR                   H(  nUR                  U;   d  M  XR                     Ul	        M*     M=     U R
                  R                   H(  nUR                  U;   d  M  XR                     Ul	        M*     U $ )a  Adds a prefix to names of elements in a graph: nodes, edges, inputs, outputs,
initializers, sparse initializer, value infos, and local functions.

It can be used as a utility before merging graphs that have overlapping names.
Empty names are not _prefixed.

Arguments:
    model (ModelProto): Model
    prefix (str): Prefix to be added to each name in the graph
    rename_nodes (bool): Whether to prefix node names
    rename_edges (bool): Whether to prefix node edge names
    rename_inputs (bool): Whether to prefix input names
    rename_outputs (bool): Whether to prefix output names
    rename_initializers (bool): Whether to prefix initializer and sparse initializer names
    rename_value_infos (bool): Whether to prefix value info nanes
    rename_functions (bool): Whether to prefix local function names
    inplace (bool): If True, mutates the model directly.
                    Otherwise, a copy will be created

Returns:
    ModelProto
#model argument is not an ONNX modelT)r   r   r   r   r   r   r   )
r/   r   r0   rY   rZ   r    r   r1   r   op_type)r   r?   r   r   r   r   r   r   rename_functionsr   m
f_name_mapr   
new_f_namer#   s                  r   r   r   4  s   D eZ((=>>L	

5!!#%/-
 
A&&J!+qvvF ! AVV99
* *99 5AI  !
 !!AyyJ&&yy1	 " Lr   c                j   [        U [        5      (       d  [        S5      eU(       d  [        5       nUR                  U 5        OU nUR                   Vs/ s H  oDR
                  PM     nnUR                   Hw  n[        UR                  5       H!  u  pxX;   d  M  USU 3-   UR                  U'   M#     [        UR                  5       H!  u  pyX;   d  M  U	SU 3-   UR                  U'   M#     My     UR
                  S-   n
UR                  R                  [        R                  " S/ U
/U
 S3[        R                  " U
 S3[        R                  S/U/S9S	95        [        [!        UR                  5      5       GH(  nUR                  R#                  S
5      nUR
                  SU 3-   nUR                  R                  [        R                  " SX/UR
                  /SUR
                   3S95        UR$                  R&                  R(                  R*                   Vs/ s H  oR,                  PM     nnUR/                  US5        UR                  R                  [        R0                  " UR
                  UR$                  R&                  R2                  U5      5        GM+     U$ s  snf s  snf )a  Inserts an extra dimension with extent 1 to each output in the graph.

Inserts an Unsqueeze node for each output. It can be used as a utility before merging graphs,
for example when the second one expects a batch dimension.

Arguments:
    graph (GraphProto): Graph
    dim_idx (int): Index of the dimension to be inserted.
                   A negative value means counting dimensions from the back.
    inplace (bool): If True, mutates the model directly.
                    Otherwise, a copy will be created

Returns:
    GraphProto
r   _collapsed_dim__expand_out_dim_idxConstantz	-constantz-valuer(   )r1   	data_typedimsvals)rb   rc   r1   r   r   	Unsqueezez
unsqueeze-)rb   rc   r1   )r/   r   r0   rY   r   r1   r   rJ   r   r   r
   	make_nodemake_tensorr   INT64rD   rI   poprF   tensor_typeshapedim	dim_valueinsertmake_tensor_value_info	elem_type)r    dim_idxr   rH   r   orig_out_namesr#   r$   outinpexpand_dim_krU   r%   prev_outputd	new_shapes                   r   expand_out_dim_graphr   ~  sK   ( eZ((=>>L	

5019fkkN9VV)FA$!ogY$?? *  (FA$ _WI#>>
 )	  6611LFFMM!N >+$$$~V,%++ 		
& 3qxx=!HHLLOff	::	#2!!&&*		
 +,&&*<*<*B*B*F*FG*FQ[[*F	G!$	))**44i	
 "$ Ha :R Hs   J+"J0c                    [        U [        5      (       d  [        S5      eU(       d  [        5       nUR                  U 5        Un [	        U R
                  USS9  U $ )a  Inserts an extra dimension with extent 1 to each output in the graph.

Inserts an Unsqueeze node for each output. It can be used as a utility before merging graphs,
for example when the second one expects a batch dimension.

Arguments:
    model (ModelProto): Model
    dim_idx (int): Index of the dimension to be inserted.
                   A negative value means counting dimensions from the back.
    inplace (bool): If True, mutates the model directly.
                    Otherwise, a copy will be created

Returns:
    ModelProto
r   T)r   )r/   r   r0   rY   r   r    )r   r   r   r   s       r   expand_out_dimr     sT    ( eZ((=>>L	

5
 Lr   r   )r4   r   r5   r   r6   zlist[tuple[str, str]] | Noner.   zlist[tuple[str, list[str]]])NNNNNN)r4   r   r5   r   r6   list[tuple[str, str]]rb   list[str] | Nonerc   r   rd   
str | Nonere   r   r1   r   ra   r   r.   r   )
NNNNNNzonnx.compose.merge_modelsz1.0r   r(   )r   r   r   r   r6   r   rb   r   rc   r   rd   r   re   r   r1   r   ra   r   r   r   r   r   r   r   r   z
int | Noner.   r   )TTTTTTFN)r    r   r?   r   r   bool | Noner   r   r   r   r   r   r   r   r   r   r   r   r   zdict[str, str] | Noner.   r   )TTTTTTTF)r   r   r?   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r.   r   )F)r    r   r   rW   r   r   r.   r   )r   r   r   rW   r   r   r.   r   )
__future__r   typingr   onnxr   r   r   r   r	   r
   r   collections.abcr   r<   r   r   rZ   r   r   r    r   r   <module>r      s&   #     . LPBB"B,HB BR  $ $!KKK "K 	K
 K K K K K Kd  $ $! ;#( !OOO "O 	O
 O O O O O O !O O O Oj !% $!%"&'+&* &*vvv v 	v
 v  v %v $v v $v vx !% $!%"&'+&*$( GGG G 	G
 G  G %G $G "G G GZ !MMM M 	Mf !!!! ! 	!r   