
    AVh              	          d Z ddlZddlmZ ddlmZ ddlmZ ddlm	Z
 ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZm Z m!Z! ddl"m#Z# g dfde#e!ejH                  f   fdZ%  ed       ejL                  e%            Z'de#e!ejH                  f   fdZ(dMde#e!ejH                  f   fdZ)  ed       ejL                  e)            Z*de#e!ejH                  f   fdZ+ ed Z,dMde,de#e!e,f   fdZ-  ed       ejL                  e-            Z.de,de#e!e,f   fdZ/dMde#e!ejH                  f   de#e!ejH                  f   d e#e!ejH                  f   fd!Z0  ed"       ejL                  e0            Z1de#e!ejH                  f   de#e!ejH                  f   d e#e!ejH                  f   fd#Z2 ed$ Z3g dfd%e#e!e3f   fd&Z4  ed'       ejL                  e4            Z5d%e#e!e3f   fd(Z6dNd)e7d*e7d+e7fd,Z8  ed-       ejL                  e8            Z9d)e7d*e7d+e7fd.Z:dMd/e#e!ejv                  f   fd0Z<  ed1       ejL                  e<            Z=d/e#e!ejv                  f   fd2Z>dNd)e7d*e7d+e7fd3Z?  ed4       ejL                  e?            Z@d)e7d*e7d+e7fd5ZAg dfde#e!ejH                  f   fd6ZB  ed7       ejL                  eB            ZCde#e!ejH                  f   fd8ZD ed9 ZEg dfd%e#e!eEf   fd:ZF  ed;       ejL                  eF            ZGd%e#e!eEf   fd<ZHg d=dfd>eIfd?ZJ  ed@       ejL                  eJ            ZKd>eIfdAZLdMdBZM  edC       ejL                  eM            ZNdD ZO edE ZPdMdFe#e!ePf   de#e!ej                  f   fdGZR  edH       ejL                  eR            ZSdFe#e!ePf   de#e!ej                  f   fdIZTg d=dfd>eIfdJZU  edK       ejL                  eU            ZVd>eIfdLZWy)OzUPython wrappers around TensorFlow ops.

This file is MACHINE GENERATED! Do not edit.
    N)
pywrap_tfe)context)core)execute)dtypes)annotation_types)op_def_registry)ops)op_def_library)deprecated_endpoints)dispatch)	tf_export)TypeVarListAny)	Annotatedbranch_indexc                    t         j                   xs t        j                         }|j                  }|j                  r"	 t	        j
                  |d|| |d|d|d|      }|S t        |t        t        f      st!        d|z        |D 
cg c]  }
t#        j$                  |
d       }}
t        |t        t        f      st!        d|z        |g }t        |t        t        f      st!        d	|z        |D cg c]  }t#        j&                  |d       }}t)        j*                  d| |||||
      \  }}}}|dd }|s|S t#        j,                         rjd|j/                  d      d|j/                  d      d|j/                  d      d|j/                  d      f}|j0                  }t#        j2                  d|||       |S # t        j                  $ r }	t        j                  |	|       Y d}	~	nd}	~	wt        j                  $ r Y nw xY w	 t        | ||||||      S # t        j                  $ r Y w xY wc c}
w c c}w )a  An n-way switch statement which calls a single branch function.

      An n-way switch statement, implementing the following:
      ```
      switch (branch_index) {
        case 0:
          output = branches[0](input);
          break;
        case 1:
          output = branches[1](input);
          break;
        ...
        case [[nbranches-1]]:
        default:
          output = branches[nbranches-1](input);
          break;
      }
      ```

  Args:
    branch_index: A `Tensor` of type `int32`.
      The branch selector, an int32 Tensor.
    input: A list of `Tensor` objects.
      A list of input tensors passed to the branch function.
    Tout: A list of `tf.DTypes`. A list of output types.
    branches: A list of functions decorated with @Defun that has length `>= 1`.
            A list of functions each of which takes 'inputs' and returns a list of
            tensors, whose types are the same as what every other branch returns.
    output_shapes: An optional list of shapes (each a `tf.TensorShape` or list of `ints`). Defaults to `[]`.
    name: A name for the operation (optional).

  Returns:
    A list of `Tensor` objects of type `Tout`.
  CaseToutbranchesoutput_shapesNr   r   r   namectx7Expected list for 'Tout' argument to 'case' Op, not %r.;Expected list for 'branches' argument to 'case' Op, not %r.@Expected list for 'output_shapes' argument to 'case' Op, not %r.r   inputr   r   r   r   Tin)_contextr   _thread_local_datais_eagerr   TFE_Py_FastPathExecute_core_NotOkStatusException_opsraise_from_not_ok_status_FallbackExceptioncase_eager_fallback_SymbolicException
isinstancelisttuple	TypeError_execute	make_type
make_shape_op_def_library_apply_op_helpermust_record_gradientget_attrinputsrecord_gradientr   r    r   r   r   r   _ctxtld_resulte_t_s__op_outputs_attrs_inputs_flats                    X/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/ops/gen_functional_ops.pycaserG      sb   F 
			0h..0$#\\11fdL%z/=2g n 
D4-	(
	#	$% % 48	8R(

R
(	8$	8	HtUm	,
	'	() ) M	MD%=	1
	,	-. . GTT8&&r?;T-T'88\T!TK!QX QK'	J""$S\\%(&#,,v2F#,,z2Oll?+-F ::Lfg/	.Q && -
##At,,## 
 
D8%Dd< < ## 
 
9 Us<     G 	H88H=HG//HHH H54H5zraw_ops.Casec                    t        |t        t        f      st        d|z        |D cg c]  }t	        j
                  |d       }}t        |t        t        f      st        d|z        |g }t        |t        t        f      st        d|z        |D cg c]  }t	        j                  |d       }}t	        j                  ||      \  }	}t        j                  | t        j                        } | gt        |      z   }
d|	d|d|d|f}t	        j                  dt        |      |
|||	      }t	        j                         rt	        j                  d
|
||       |S c c}w c c}w )Nr   r   r   r   r   r!   r   s   Caser8   attrsr   r   r   r-   r.   r/   r0   r1   r2   r3   convert_to_mixed_eager_tensorsr(   convert_to_tensor_dtypesint32r   lenr6   r9   r   r    r   r   r   r   r   r?   r@   	_attr_TinrE   rD   r=   s                rF   r+   r+   q   sw   	D4-	(
	#	$% % 48	8R(

R
(	8$	8	HtUm	,
	'	() ) M	MD%=	1
	,	-. . GTT8&&r?;T-T<<UCH)U''gmmD,$u+-,9fdJ="&Wc$i#)s?'""$fg/	.- 
9 U   EE$returnc                    t         j                   xs t        j                         }|j                  }|j                  r	 t	        j
                  |d|d|       }|S t        | t        t        f      st!        d| z        | D cg c]  }t#        j$                  |d       } }t'        j(                  d| |      \  }}}}	|	dd }t#        j*                         r7d|j-                  d      f}
|j.                  }t#        j0                  d||
|       |\  }|S # t        j                  $ r }t        j                  ||       Y d}~nd}~wt        j                  $ r Y nw xY w	 t        | ||      S # t        j                  $ r Y )w xY wc c}w )a  Return the index of device the op runs.

  Given a list of device names, this operation returns the index of the device
  this op runs. The length of the list is returned in two cases:
  (1) Device does not exist in the given device list.
  (2) It is in XLA compilation.

  Args:
    device_names: A list of `strings`.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `int32`.
  DeviceIndexdevice_namesN)rW   r   r   GExpected list for 'device_names' argument to 'device_index' Op, not %r.)rW   r   )r"   r   r#   r$   r   r%   r&   r'   r(   r)   r*   device_index_eager_fallbackr,   r-   r.   r/   r0   r1   make_strr4   r5   r6   r7   r8   r9   )rW   r   r;   r<   r=   r>   r@   rA   rB   rC   rD   rE   s               rF   device_indexr[      s    
			0h..0$#\\11mT><Agn 
L4-	0
	%'3	45 5 COOB(##B7O,O'88Lt=!QXQK'""$cll>:;F::L|VW6('	.1 && -
##At,,## 
(#$D: :## 
 Ps6    D FE(EEE E. .FFzraw_ops.DeviceIndexc                 @   t        | t        t        f      st        d| z        | D cg c]  }t	        j
                  |d       } }g }d| f}t	        j                  dd||||      }t	        j                         rt	        j                  d|||       |\  }|S c c}w )NrX   rW   s   DeviceIndex   rI   rV   )	r-   r.   r/   r0   r1   rZ   r   r6   r9   )rW   r   r   r@   rE   rD   r=   s          rF   rY   rY      s    	L4-	0
	%'3	45 5 COOB(##B7O,O,L)&^Q|#)s?'""$|VW6('	. Ps   B) TV_FakeParam_dtype_atypes.BFloat16_atypes.Bool_atypes.Complex128_atypes.Complex64_atypes.Float16_atypes.Float32_atypes.Float64_atypes.Float8e4m3b11fnuz_atypes.Float8e4m3fn_atypes.Float8e4m3fnuz_atypes.Float8e5m2_atypes.Float8e5m2fnuz_atypes.Half_atypes.Int16_atypes.Int32_atypes.Int4_atypes.Int64_atypes.Int8_atypes.QInt16_atypes.QInt32_atypes.QInt8_atypes.QUInt16_atypes.QUInt8_atypes.Resource_atypes.String_atypes.UInt16_atypes.UInt32_atypes.UInt4_atypes.UInt64_atypes.UInt8_atypes.Variantdtypec           	         t         j                   xs t        j                         }|j                  }|j                  r	 t	        j
                  |d|d| d|      }|S t        j                  | d      } t        j                  |d      }t!        j"                  d| ||      \  }}}}	|	dd }t        j$                         rHd|j'                  d      d|j)                  d      f}
|j*                  }t        j,                  d||
|       |\  }|S # t        j                  $ r }t        j                  ||       Y d}~nd}~wt        j                  $ r Y nw xY w	 t        | |||      S # t        j                  $ r Y !w xY w)a    This op is used as a placeholder in If branch functions. It doesn't provide a
  valid output when run, so must either be removed (e.g. replaced with a
  function input) or guaranteed not to be used (e.g. if mirroring an
  intermediate output needed for the gradient computation of the other branch).

  Args:
    dtype: A `tf.DType`. The type of the output.
    shape: A `tf.TensorShape` or list of `ints`.
          The purported shape of the output. This is only used for shape inference;
          the output will not necessarily have this shape. Can be a partial shape.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `dtype`.
  	FakeParamr~   shapeN)r~   r   r   r   )r~   r   r   )r"   r   r#   r$   r   r%   r&   r'   r(   r)   r*   fake_param_eager_fallbackr,   r1   r2   r3   r4   r5   r6   _get_attr_typer7   r8   r9   )r~   r   r   r;   r<   r=   r>   rA   rB   rC   rD   rE   s               rF   
fake_paramr      sv     
			0h..0$#\\11k4%%Agn 

UG
,%


eW
-%'885D:!QXQK'""$s))'2Gll7#%F::L\674('	.- && -
##At,,## 
&U49 9## 
s0    D E!D<<EEE( (E?>E?zraw_ops.FakeParamc                    t        j                  | d      } t        j                  |d      }g }d| d|f}t        j                  dd||||      }t        j                         rt        j
                  d|||       |\  }|S )Nr~   r   s	   FakeParamr]   rI   r   )r1   r2   r3   r   r6   r9   )r~   r   r   r   rE   rD   r=   s          rF   r   r     s    


UG
,%


eW
-%,UGU+&\1\#)s?'""$\674('	.    startlimitdeltac                    t         j                   xs t        j                         }|j                  }|j                  r 	 t	        j
                  |d|| |||d|	      }|S t        j                  d| |||||      \  }
}
}}|dd }t        j                          rHd|j#                  d      d|j#                  d      f}|j$                  }t        j&                  d|||       |S # t        j                  $ r }	t        j                  |	|       Y d}	~	nd}	~	wt        j                  $ r Y nw xY w	 t        | ||||||      S # t        j                  $ r Y w xY w)a  Applies a for loop.

    ```python
     output = input;
     for i in range(start, limit, delta)
       output = body(i, output);
    ```

  Args:
    start: A `Tensor` of type `int32`. The lower bound. An int32
    limit: A `Tensor` of type `int32`. The upper bound. An int32
    delta: A `Tensor` of type `int32`. The increment. An int32
    input: A list of `Tensor` objects.
      A list of input tensors whose types are T.
    body: A function decorated with @Defun.
          A function that takes a list of tensors (int32, T) and returns another
          list of tensors (T).
    name: A name for the operation (optional).

  Returns:
    A list of `Tensor` objects. Has the same type as `input`.
  ForbodyN)r   r   r   )r   r   r   r    r   r   T)r"   r   r#   r$   r   r%   r&   r'   r(   r)   r*   _for_eager_fallbackr,   r4   r5   r1   r6   r7   r8   r9   )r   r   r   r    r   r   r;   r<   r=   r>   rA   rB   rC   rD   rE   s                  rF   _forr     s[   . 
			0h..0$#\\11eT5%vtEgn (88U%uE!QX QK'""$3<<$fcll6.BCF::L|VW.	.' && -
##At,,## 
 
u4dF F## 
s0    C# #D*6DD*)D*.E   EEzraw_ops.Forc                    t        j                  ||      \  }}t        j                  | t        j
                        } t        j                  |t        j
                        }t        j                  |t        j
                        }| ||gt        |      z   }d|d|f}	t        j                  dt        |      ||	||      }
t        j                         rt        j                  d||	|
       |
S )Nr   r   s   ForrI   r   )r1   rL   r(   rM   rN   rO   r.   r   rP   r6   r9   )r   r   r   r    r   r   r   _attr_TrE   rD   r=   s              rF   r   r   K  s    ::5#F.'5

 
 
6%

 
 
6%

 
 
6%&e4,&$'&VSZ#)s?'""$|VW.	.r   ) TV_If_Tcondr_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   condc                    t         j                   xs t        j                         }|j                  }|j                  r$	 t	        j
                  |d|| |d|d|d|d|      }	|	S t        |t        t        f      st!        d|z        |D cg c]  }t#        j$                  |d       }}|g }t        |t        t        f      st!        d	|z        |D cg c]  }t#        j&                  |d       }}t)        j*                  d| ||||||
      \  }}}}|dd }	|	s|S t#        j,                         rd|j/                  d      d|j1                  d      d|j1                  d      d|j1                  d      d|j1                  d      d|j1                  d      f}|j2                  }t#        j4                  d|||	       |	S # t        j                  $ r }
t        j                  |
|       Y d}
~
nd}
~
wt        j                  $ r Y nw xY w	 t        | |||||||      S # t        j                  $ r Y w xY wc c}w c c}w )a  output = cond ? then_branch(input) : else_branch(input)

  Args:
    cond: A `Tensor`.
            A Tensor. If the tensor is a scalar of non-boolean type, the
            scalar is converted to a boolean according to the
            following rule: if the scalar is a numerical value, non-zero means
            `True` and zero means False; if the scalar is a string, non-empty
            means `True` and empty means `False`. If the tensor is not a scalar,
            being empty means False and being non-empty means True.
    input: A list of `Tensor` objects. A list of input tensors.
    Tout: A list of `tf.DTypes`. A list of output types.
    then_branch: A function decorated with @Defun.
            A function that takes 'inputs' and returns a list of tensors, whose
            types are the same as what else_branch returns.
    else_branch: A function decorated with @Defun.
          A function that takes 'inputs' and returns a list of tensors, whose
          types are the same as what then_branch returns.
    output_shapes: An optional list of shapes (each a `tf.TensorShape` or list of `ints`). Defaults to `[]`.
    name: A name for the operation (optional).

  Returns:
    A list of `Tensor` objects of type `Tout`.
  Ifr   then_branchelse_branchr   Nr   r   r   r   r   r   5Expected list for 'Tout' argument to 'if' Op, not %r.>Expected list for 'output_shapes' argument to 'if' Op, not %r.r   r    r   r   r   r   r   Tcondr!   )r"   r   r#   r$   r   r%   r&   r'   r(   r)   r*   _if_eager_fallbackr,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r   r7   r8   r9   r   r    r   r   r   r   r   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   s                     rF   _ifr   \  s_   2 
			0h..0$#\\	11dD$vt]]Kg n 
D4-	(
	!	"# # 48	8R(

R
(	8$	8M	MD%=	1
	*	+, , GTT8&&r?;T-T'884u4[%]O!QX QK'	J""$s))'2Ell5!63<<+?S\\-8-ll=)?ll?+	-F
 ::LlFG-	.O && -
##At,,## 

Dk!T  ## 
 
9 Us<    "G H:H?H	G00H	H	H   H76H7z
raw_ops.Ifc                    t        |t        t        f      st        d|z        |D cg c]  }t	        j
                  |d       }}|g }t        |t        t        f      st        d|z        |D 	cg c]  }	t	        j                  |	d       }}	t	        j                  | g|g       \  }
\  } t	        j                  ||      \  }}| gt        |      z   }d|
d|d|d|d|d|f}t	        j                  d	t        |      ||||
      }t	        j                         rt	        j                  d|||       |S c c}w c c}	w )Nr   r   r   r   r   r!   r   r   s   IfrI   r   r-   r.   r/   r0   r1   r2   r3   args_to_matching_eagerrL   r   rP   r6   r9   r   r    r   r   r   r   r   r   r?   r@   _attr_TcondrR   rE   rD   r=   s                  rF   r   r     s_   	D4-	(
	!	"# # 48	8R(

R
(	8$	8M	MD%=	1
	*	+, , GTT8&&r?;T-T!88$bI+w<<UCH)U$u+%,[%FDm[/& UCIl#)s?'""$lFG-	.' 
9 U   D84D=configconfig_protoexecutor_typec                 ~   t         j                   xs t        j                         }|j                  }|j                  r%	 t	        j
                  |d|| d|d|d|d|d|      }	|	S t        |t        t        f      st!        d	|z        |D cg c]  }t#        j$                  |d       }}|d
}t#        j&                  |d      }|d
}t#        j&                  |d      }|d
}t#        j&                  |d      }t)        j*                  d| ||||||      \  }}}}|dd }	t#        j,                         rd|j/                  d      d|j/                  d      d|j/                  d      d|j/                  d      d|j/                  d      d|j/                  d      f}|j0                  }t#        j2                  d|||	       |	S # t        j                  $ r }
t        j                  |
|       Y d}
~
nd}
~
wt        j                  $ r Y nw xY w	 t        | |||||||      S # t        j                  $ r Y w xY wc c}w )a0  returns `f(inputs)`, where `f`'s body is placed and partitioned.

  Asynchronously executes a function, potentially across multiple devices but
  within a single process. The kernel places and partitions a given function's
  underlying graph, and executes each of the partitioned subgraphs as a function.

  Args:
    args: A list of `Tensor` objects. A list of input tensors.
    Tout: A list of `tf.DTypes`. A list of output types.
    f: A function decorated with @Defun.
            A function that takes 'args', a list of tensors, and returns 'output',
            another list of tensors. Input and output types are specified by 'Tin'
            and 'Tout'. The function body of f will be placed and partitioned across
            devices, setting this op apart from the regular Call op.
    config: An optional `string`. Defaults to `""`.
    config_proto: An optional `string`. Defaults to `""`.
    executor_type: An optional `string`. Defaults to `""`.
    name: A name for the operation (optional).

  Returns:
    A list of `Tensor` objects of type `Tout`.
  PartitionedCallr   fr   r   r   Nr   r   r   r   r   r   r   CExpected list for 'Tout' argument to 'partitioned_call' Op, not %r. argsr   r   r   r   r   r   r!   )r"   r   r#   r$   r   r%   r&   r'   r(   r)   r*   partitioned_call_eager_fallbackr,   r-   r.   r/   r0   r1   r2   rZ   r4   r5   r6   r7   r8   r9   r   r   r   r   r   r   r   r;   r<   r=   r>   r?   rA   rB   rC   rD   rE   s                    rF   partitioned_callr     sP   . 
			0h..0$#\\11tVT38o}Ng n 
D4-	(
	)+/	01 1 48	8R(

R
(	8$	8^FVX.&L""<@,M##M?C-'8841V(4)6TC!QX QK'""$S\\%(&#,,v2Fll33<<+Acll>:Oll?+-F ::L<:	.M && -
##At,,## 
,
TQvL%Dd< < ## 
 
9s6    #G H:H	G00H	H	H   H76H7zraw_ops.PartitionedCallc                 >   t        |t        t        f      st        d|z        |D cg c]  }t	        j
                  |d       }}|d}t	        j                  |d      }|d}t	        j                  |d      }|d}t	        j                  |d      }t	        j                  | |      \  }	} t        |       }
d|	d|d|d|d|d|f}t	        j                  d	t        |      |
|||
      }t	        j                         rt	        j                  d|
||       |S c c}w )Nr   r   r   r   r   r   r!   r   s   PartitionedCallrI   r   r-   r.   r/   r0   r1   r2   rZ   rL   r   rP   r6   r9   r   r   r   r   r   r   r   r   r?   rR   rE   rD   r=   s                rF   r   r     s5   	D4-	(
	)+/	01 1 48	8R(

R
(	8$	8^FVX.&L""<@,M##M?C-;;D#F/)Td,9fdCHf,@&/T$0C"&(' ""$<:	.) 
9   Dtargetc                 r   t         j                   xs t        j                         }|j                  }|j                  r 	 t	        j
                  |d|| |d|d|	      }|S t        |t        t        f      st!        d|z        |D 	cg c]  }	t#        j$                  |	d       }}	t'        j(                  d| ||||      \  }
}
}}|dd }|s|S t#        j*                         rYd|j-                  d      d|j-                  d      d|j-                  d      f}|j.                  }t#        j0                  d|||       |S # t        j                  $ r }t        j                  ||       Y d}~nd}~wt        j                  $ r Y nw xY w	 t        | |||||      S # t        j                  $ r Y Qw xY wc c}	w )	a  Runs function `f` on a remote device indicated by `target`.

  Args:
    target: A `Tensor` of type `string`.
      A fully specified device name where we want to run the function.
    args: A list of `Tensor` objects. A list of arguments for the function.
    Tout: A list of `tf.DTypes` that has length `>= 1`.
      The type list for the return values.
    f: A function decorated with @Defun. The function to run remotely.
    name: A name for the operation (optional).

  Returns:
    A list of `Tensor` objects of type `Tout`.
  
RemoteCallr   r   Nr   r   r   r   >Expected list for 'Tout' argument to 'remote_call' Op, not %r.)r   r   r   r   r   r!   )r"   r   r#   r$   r   r%   r&   r'   r(   r)   r*   remote_call_eager_fallbackr,   r-   r.   r/   r0   r1   r2   r4   r5   r6   r7   r8   r9   )r   r   r   r   r   r;   r<   r=   r>   r?   rA   rB   rC   rD   rE   s                  rF   remote_callr   +  s    
			0h..0$#\\11lD&$c1Fgn 
D4-	(
	$&*	+, , 48	8R(

R
(	8$	8'88V$TQTK!QXQK'	J""$S\\%(&#,,v2Fll3!F::LlFG5	.5 && -
##At,,## 
'
$TQTt= =## 
 
9s6    D> F4>FE,,FF	F F10F1zraw_ops.RemoteCallc                    t        |t        t        f      st        d|z        |D cg c]  }t	        j
                  |d       }}t	        j                  ||      \  }}t        j                  | t        j                        } | gt        |      z   }d|d|d|f}	t	        j                  dt        |      ||	||      }
t	        j                         rt	        j                  d||	|
       |
S c c}w )Nr   r   r!   r   s
   RemoteCallrI   r   )r-   r.   r/   r0   r1   r2   rL   r(   rM   rN   stringr   rP   r6   r9   )r   r   r   r   r   r   r?   rR   rE   rD   r=   s              rF   r   r   `  s    	D4-	(
	$&*	+, , 48	8R(

R
(	8$	8;;D#F/)T!!&'..9&DJ&,9fdC3&]CIl#)s?'""$lFG5	. 
9s   C.c                    t         j                   xs t        j                         }|j                  }|j                  r%	 t	        j
                  |d|| d|d|d|d|d|      }	|	S t        |t        t        f      st!        d	|z        |D cg c]  }t#        j$                  |d       }}|d
}t#        j&                  |d      }|d
}t#        j&                  |d      }|d
}t#        j&                  |d      }t)        j*                  d| ||||||      \  }}}}|dd }	|	s|S t#        j,                         rd|j/                  d      d|j/                  d      d|j/                  d      d|j/                  d      d|j/                  d      d|j/                  d      f}|j0                  }t#        j2                  d|||	       |	S # t        j                  $ r }
t        j                  |
|       Y d}
~
nd}
~
wt        j                  $ r Y nw xY w	 t        | |||||||      S # t        j                  $ r Y w xY wc c}w )aa  returns `f(inputs)`, where `f`'s body is placed and partitioned.

  Args:
    args: A list of `Tensor` objects. A list of input tensors.
    Tout: A list of `tf.DTypes`. A list of output types.
    f: A function decorated with @Defun.
            A function that takes 'args', a list of tensors, and returns 'output',
            another list of tensors. Input and output types are specified by 'Tin'
            and 'Tout'. The function body of f will be placed and partitioned across
            devices, setting this op apart from the regular Call op. This op is
            stateful.
    config: An optional `string`. Defaults to `""`.
    config_proto: An optional `string`. Defaults to `""`.
    executor_type: An optional `string`. Defaults to `""`.
    name: A name for the operation (optional).

  Returns:
    A list of `Tensor` objects of type `Tout`.
  StatefulPartitionedCallr   r   r   r   r   Nr   LExpected list for 'Tout' argument to 'stateful_partitioned_call' Op, not %r.r   r   r!   )r"   r   r#   r$   r   r%   r&   r'   r(   r)   r*   (stateful_partitioned_call_eager_fallbackr,   r-   r.   r/   r0   r1   r2   rZ   r4   r5   r6   r7   r8   r9   r   s                    rF   stateful_partitioned_callr   r  sY   ( 
			0h..0$#\\	11'tVT3&.,g n 
D4-	(
	248	9: : 48	8R(

R
(	8$	8^FVX.&L""<@,M##M?C-'88!41V0<1>TK!QX QK'	J""$S\\%(&#,,v2Fll33<<+Acll>:Oll?+-F ::L!<B	.Q && -
##At,,## 
5
TQvL%Dd< < ## 
 
9s6    #G H>HG44HHH$ $H;:H;zraw_ops.StatefulPartitionedCallc                 >   t        |t        t        f      st        d|z        |D cg c]  }t	        j
                  |d       }}|d}t	        j                  |d      }|d}t	        j                  |d      }|d}t	        j                  |d      }t	        j                  | |      \  }	} t        |       }
d|	d|d|d|d|d|f}t	        j                  d	t        |      |
|||
      }t	        j                         rt	        j                  d|
||       |S c c}w )Nr   r   r   r   r   r   r!   r   s   StatefulPartitionedCallrI   r   r   r   s                rF   r   r     s6   	D4-	(
	248	9: : 48	8R(

R
(	8$	8^FVX.&L""<@,M##M?C-;;D#F/)Td,9fdCHf,@&7T$0C"&(' ""$!<B	.) 
9r   c                 |   t         j                   xs t        j                         }|j                  }|j                  r"	 t	        j
                  |d|| |d|d|d|      }|S t        |t        t        f      st!        d|z        |D 
cg c]  }
t#        j$                  |
d       }}
t        |t        t        f      st!        d|z        |g }t        |t        t        f      st!        d	|z        |D cg c]  }t#        j&                  |d       }}t)        j*                  d| |||||
      \  }}}}|dd }t#        j,                         rjd|j/                  d      d|j/                  d      d|j/                  d      d|j/                  d      f}|j0                  }t#        j2                  d|||       |S # t        j                  $ r }	t        j                  |	|       Y d}	~	nd}	~	wt        j                  $ r Y nw xY w	 t        | ||||||      S # t        j                  $ r Y w xY wc c}
w c c}w )a  An n-way switch statement which calls a single branch function.

      An n-way switch statement, implementing the following:
      ```
      switch (branch_index) {
        case 0:
          output = branches[0](input);
          break;
        case 1:
          output = branches[1](input);
          break;
        ...
        case [[nbranches-1]]:
        default:
          output = branches[nbranches-1](input);
          break;
      }
      ```

      This should only be used when the none of branches has stateful ops.

  Args:
    branch_index: A `Tensor` of type `int32`.
      The branch selector, an int32 Tensor.
    input: A list of `Tensor` objects.
      A list of input tensors passed to the branch function.
    Tout: A list of `tf.DTypes`. A list of output types.
    branches: A list of functions decorated with @Defun that has length `>= 1`.
            A list of functions each of which takes 'inputs' and returns a list of
            tensors, whose types are the same as what every other branch returns.
    output_shapes: An optional list of shapes (each a `tf.TensorShape` or list of `ints`). Defaults to `[]`.
    name: A name for the operation (optional).

  Returns:
    A list of `Tensor` objects of type `Tout`.
  StatelessCaser   r   r   Nr   AExpected list for 'Tout' argument to 'stateless_case' Op, not %r.EExpected list for 'branches' argument to 'stateless_case' Op, not %r.JExpected list for 'output_shapes' argument to 'stateless_case' Op, not %r.r   r!   )r"   r   r#   r$   r   r%   r&   r'   r(   r)   r*   stateless_case_eager_fallbackr,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   s                    rF   stateless_caser     sZ   J 
			0h..0$#\\11ot\5&$Ho}>g n 
D4-	(
	')-	./ / 48	8R(

R
(	8$	8	HtUm	,
	')1	23 3 M	MD%=	1
	')6	78 8 GTT8&&r?;T-T'88l%d"*-"$!QX QK'""$S\\%(&#,,v2F#,,z2Oll?+-F ::Lvw8	.O && -
##At,,## 
*
D8%Dd< < ## 
 
9 Us<     F= 	H48H9=HG++HHH H10H1zraw_ops.StatelessCasec                    t        |t        t        f      st        d|z        |D cg c]  }t	        j
                  |d       }}t        |t        t        f      st        d|z        |g }t        |t        t        f      st        d|z        |D cg c]  }t	        j                  |d       }}t	        j                  ||      \  }	}t        j                  | t        j                        } | gt        |      z   }
d|	d|d|d|f}t	        j                  dt        |      |
|||	      }t	        j                         rt	        j                  d
|
||       |S c c}w c c}w )Nr   r   r   r   r   r!   r   s   StatelessCaserI   r   rK   rQ   s                rF   r   r   1  sx   	D4-	(
	')-	./ / 48	8R(

R
(	8$	8	HtUm	,
	')1	23 3 M	MD%=	1
	')6	78 8 GTT8&&r?;T-T<<UCH)U''gmmD,$u+-,9fdJ="&-s4y#)s?'""$vw8	.- 
9 UrS   ) TV_StatelessIf_Tcondr_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   c                    t         j                   xs t        j                         }|j                  }|j                  r$	 t	        j
                  |d|| |d|d|d|d|      }	|	S t        |t        t        f      st!        d|z        |D cg c]  }t#        j$                  |d       }}|g }t        |t        t        f      st!        d	|z        |D cg c]  }t#        j&                  |d       }}t)        j*                  d| ||||||
      \  }}}}|dd }	t#        j,                         rd|j/                  d      d|j1                  d      d|j1                  d      d|j1                  d      d|j1                  d      d|j1                  d      f}|j2                  }t#        j4                  d|||	       |	S # t        j                  $ r }
t        j                  |
|       Y d}
~
nd}
~
wt        j                  $ r Y nw xY w	 t        | |||||||      S # t        j                  $ r Y w xY wc c}w c c}w )aM  output = cond ? then_branch(input) : else_branch(input)

  Args:
    cond: A `Tensor`.
            A Tensor. If the tensor is a scalar of non-boolean type, the
            scalar is converted to a boolean according to the
            following rule: if the scalar is a numerical value, non-zero means
            `True` and zero means False; if the scalar is a string, non-empty
            means `True` and empty means `False`. If the tensor is not a scalar,
            being empty means False and being non-empty means True.

            This should only be used when the if then/else body functions do not
            have stateful ops.
    input: A list of `Tensor` objects. A list of input tensors.
    Tout: A list of `tf.DTypes`. A list of output types.
    then_branch: A function decorated with @Defun.
            A function that takes 'inputs' and returns a list of tensors, whose
            types are the same as what else_branch returns.
    else_branch: A function decorated with @Defun.
          A function that takes 'inputs' and returns a list of tensors, whose
          types are the same as what then_branch returns.
    output_shapes: An optional list of shapes (each a `tf.TensorShape` or list of `ints`). Defaults to `[]`.
    name: A name for the operation (optional).

  Returns:
    A list of `Tensor` objects of type `Tout`.
  StatelessIfr   r   r   r   Nr   ?Expected list for 'Tout' argument to 'stateless_if' Op, not %r.HExpected list for 'output_shapes' argument to 'stateless_if' Op, not %r.r   r   r!   )r"   r   r#   r$   r   r%   r&   r'   r(   r)   r*   stateless_if_eager_fallbackr,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r   r7   r8   r9   r   s                     rF   stateless_ifr   Q  sW   8 
			0h..0$#\\	11mT4m]Kg n 
D4-	(
	%'+	,- - 48	8R(

R
(	8$	8M	MD%=	1
	%'4	56 6 GTT8&&r?;T-T'88DD#.K%2?!QX QK'""$s))'2Ell5!63<<+?S\\-8-ll=)?ll?+	-F
 ::L|VW6	.M && -
##At,,## 
(
Dk!T  ## 
 
9 Us<    "F> H6H;>HG,,HH	H H32H3zraw_ops.StatelessIfc                    t        |t        t        f      st        d|z        |D cg c]  }t	        j
                  |d       }}|g }t        |t        t        f      st        d|z        |D 	cg c]  }	t	        j                  |	d       }}	t	        j                  | g|g       \  }
\  } t	        j                  ||      \  }}| gt        |      z   }d|
d|d|d|d|d|f}t	        j                  d	t        |      ||||
      }t	        j                         rt	        j                  d|||       |S c c}w c c}	w )Nr   r   r   r   r   r!   r   r   s   StatelessIfrI   r   r   r   s                  rF   r   r     s_   	D4-	(
	%'+	,- - 48	8R(

R
(	8$	8M	MD%=	1
	%'4	56 6 GTT8&&r?;T-T!88$bI+w<<UCH)U$u+%,[%FDm[/& ^SY|#)s?'""$|VW6	.' 
9 Ur   
   parallel_iterationsc                    t         j                   xs t        j                         }|j                  }|j                  r#	 t	        j
                  |d|| d|d|d|d|      }|S |g }t        |t        t        f      st!        d|z        |D 
cg c]  }
t#        j$                  |
d       }}
|d	}t#        j&                  |d      }t)        j*                  d| |||||
      \  }}}}|dd }t#        j,                         r{d|j/                  d      d|j/                  d      d|j/                  d      d|j/                  d      d|j1                  d      f
}|j2                  }t#        j4                  d|||       |S # t        j                  $ r }	t        j                  |	|       Y d}	~	nd}	~	wt        j                  $ r Y nw xY w	 t        | ||||||      S # t        j                  $ r Y w xY wc c}
w )a  output = input; While (Cond(output)) { output = Body(output) }

  Args:
    input: A list of `Tensor` objects.
      A list of input tensors whose types are T.
    cond: A function decorated with @Defun.
            A function takes 'input' and returns a tensor.  If the tensor is
            a scalar of non-boolean, the scalar is converted to a boolean
            according to the following rule: if the scalar is a numerical
            value, non-zero means True and zero means False; if the scalar is
            a string, non-empty means True and empty means False. If the
            tensor is not a scalar, non-emptiness means True and False
            otherwise.

            This should only be used when the while condition and body functions
            do not have stateful ops.
    body: A function decorated with @Defun.
            A function that takes a list of tensors and returns another
            list of tensors. Both lists have the same types as specified
            by T.
    output_shapes: An optional list of shapes (each a `tf.TensorShape` or list of `ints`). Defaults to `[]`.
    parallel_iterations: An optional `int`. Defaults to `10`.
    name: A name for the operation (optional).

  Returns:
    A list of `Tensor` objects. Has the same type as `input`.
  StatelessWhiler   r   r   r   Nr   r   r   r   r   r   KExpected list for 'output_shapes' argument to 'stateless_while' Op, not %r.r   r    r   r   r   r   r   r   )r"   r   r#   r$   r   r%   r&   r'   r(   r)   r*   stateless_while_eager_fallbackr,   r-   r.   r/   r0   r1   r3   make_intr4   r5   r6   r7   _get_attr_intr8   r9   r    r   r   r   r   r   r;   r<   r=   r>   r@   rA   rB   rC   rD   rE   s                   rF   stateless_whiler     s   8 
			0h..0$#\\	11eVT64(=g n M	MD%=	1
	(*7	89 9 GTT8&&r?;T-T  ))*=?TU'88Dt(5.AN!QX QK'""$3<<$fcll6.BFll6"Oll?+-B 568F ::L,9	.E && -
##At,,## 
+
d]1$H H ## 
 Us6    !E> G5>GF,,GG	G G21G2zraw_ops.StatelessWhilec           
         |g }t        |t        t        f      st        d|z        |D cg c]  }t	        j
                  |d       }}|d}t	        j                  |d      }t	        j                  | |      \  }} t        |       }	d|d|d|d|d|f
}
t	        j                  dt        |       |	|
||	      }t	        j                         rt	        j                  d
|	|
|       |S c c}w )Nr   r   r   r   r   r   r   s   StatelessWhilerI   r   r-   r.   r/   r0   r1   r3   r   rL   r   rP   r6   r9   r    r   r   r   r   r   r   r@   r   rE   rD   r=   s               rF   r   r     s   M	MD%=	1
	(*7	89 9 GTT8&&r?;T-T  ))*=?TU::5#F.'5e,&$o&(;=&.E
$0C"&(' ""$,9	. U   C(c           
      d   t         j                   xs t        j                         }|j                  }|j                  r	 t	        j
                  |d|| d|d|      }|S t        |t        t        f      st!        d|z        |D cg c]  }t#        j$                  |d       }}t'        j(                  d| |||      \  }	}	}
}|dd }t#        j*                         rYd|
j-                  d      d|
j-                  d      d|
j-                  d      f}|
j.                  }t#        j0                  d|||       |S # t        j                  $ r }t        j                  ||       Y d}~nd}~wt        j                  $ r Y nw xY w	 t        | ||||      S # t        j                  $ r Y Kw xY wc c}w )	a  Computes the gradient function for function f via backpropagation.

  Args:
    input: A list of `Tensor` objects. a list of input tensors of size N + M;
    Tout: A list of `tf.DTypes` that has length `>= 1`.
      the type list for the input list.
    f: A function decorated with @Defun.
      The function we want to compute the gradient for.

      The function 'f' must be a numerical function which takes N inputs and
      produces M outputs. Its gradient function 'g', which is computed by
      this SymbolicGradient op is a function taking N + M inputs and
      produces N outputs.

      I.e. if we have
         (y1, y2, ..., y_M) = f(x1, x2, ..., x_N),
      then, g is
         (dL/dx1, dL/dx2, ..., dL/dx_N) = g(x1, x2, ..., x_N,
                                           dL/dy1, dL/dy2, ..., dL/dy_M),

      where L is a scalar-value function of (x1, x2, ..., xN) (e.g., the
      loss function). dL/dx_i is the partial derivative of L with respect
      to x_i.

      (Needs some math expert to say the comment above better.)
    name: A name for the operation (optional).

  Returns:
    A list of `Tensor` objects of type `Tout`.
  SymbolicGradientr   r   Nr   DExpected list for 'Tout' argument to 'symbolic_gradient' Op, not %r.)r    r   r   r   r!   )r"   r   r#   r$   r   r%   r&   r'   r(   r)   r*    symbolic_gradient_eager_fallbackr,   r-   r.   r/   r0   r1   r2   r4   r5   r6   r7   r8   r9   )r    r   r   r   r;   r<   r=   r>   r?   rA   rB   rC   rD   rE   s                 rF   symbolic_gradientr      s   > 
			0h..0$#\\11 $vtS!Egn 
D4-	(
	*,0	12 2 48	8R(

R
(	8$	8'88%dadD!QXQK'""$S\\%(&#,,v2Fll3!F::LL&';	.1 && -
##At,,## 
-
dad6 6## 
 
9s6    D8 F-8E?E&&E?>E?F F*)F*zraw_ops.SymbolicGradientc                    t        |t        t        f      st        d|z        |D cg c]  }t	        j
                  |d       }}t	        j                  | |      \  }} t        |       }d|d|d|f}t	        j                  dt        |      ||||      }	t	        j                         rt	        j                  d|||	       |	S c c}w )Nr   r   r!   r   s   SymbolicGradientrI   r   )r-   r.   r/   r0   r1   r2   rL   r   rP   r6   r9   )
r    r   r   r   r   r?   rR   rE   rD   r=   s
             rF   r   r   c  s    	D4-	(
	*,0	12 2 48	8R(

R
(	8$	8<<UCH)Ue,9fdC3&0#d)$0C"&(' ""$L&';	. 
9s   C) TV_ToBool_Tr_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   r    c                 ~   t         j                   xs t        j                         }|j                  }|j                  r	 t	        j
                  |d||       }|S t        j                  d| |      \  }}}}|dd }t        j                          r7d|j#                  d      f}	|j$                  }
t        j&                  d|
|	|       |\  }|S # t        j                  $ r }t        j                  ||       Y d}~nd}~wt        j                  $ r Y nw xY w	 t        | ||      S # t        j                  $ r Y w xY w)a  Converts a tensor to a scalar predicate.

  Converts a tensor to a scalar predicate with the following rules:

  - For 0D tensors, truthiness is determined by comparing against a "zero"
    value. For numerical types it is the obvious zero. For strings it is the
    empty string.

  - For >0D tensors, truthiness is determined by looking at the number of
    elements. If has zero elements, then the result is false. Otherwise the
    result is true.

  This matches the behavior of If and While for determining if a tensor counts
  as true/false for a branch condition.

  Args:
    input: A `Tensor`.
    name: A name for the operation (optional).

  Returns:
    A `Tensor` of type `bool`.
  ToBoolN)r   r   )r    r   r   )r"   r   r#   r$   r   r%   r&   r'   r(   r)   r*   to_bool_eager_fallbackr,   r4   r5   r1   r6   r   r8   r9   )r    r   r;   r<   r=   r>   rA   rB   rC   rD   rE   s              rF   to_boolr   w  s7   . 
			0h..0$#\\11he%gn (88D*!QXQK'""$3%%c*+F::L,1('	.' && -
##At,,## 
#
d& &## 
s0    C D C;;DDD& &D<;D<zraw_ops.ToBoolc                     t        j                  | g|g       \  }\  } | g}d|f}t        j                  dd||||      }t        j                         rt        j                  d|||       |\  }|S )Nr   s   ToBoolr]   rI   r   )r1   r   r   r6   r9   )r    r   r   r   rE   rD   r=   s          rF   r   r     s{    55ugsBG'8E,>&Y,f!$41'""$,1('	.r   c                    t         j                   xs t        j                         }|j                  }|j                  r#	 t	        j
                  |d|| d|d|d|d|      }|S |g }t        |t        t        f      st!        d|z        |D 
cg c]  }
t#        j$                  |
d       }}
|d	}t#        j&                  |d      }t)        j*                  d| |||||
      \  }}}}|dd }|s|S t#        j,                         r{d|j/                  d      d|j/                  d      d|j/                  d      d|j/                  d      d|j1                  d      f
}|j2                  }t#        j4                  d|||       |S # t        j                  $ r }	t        j                  |	|       Y d}	~	nd}	~	wt        j                  $ r Y nw xY w	 t        | ||||||      S # t        j                  $ r Y w xY wc c}
w )a  output = input; While (Cond(output)) { output = Body(output) }

  Args:
    input: A list of `Tensor` objects.
      A list of input tensors whose types are T.
    cond: A function decorated with @Defun.
            A function takes 'input' and returns a tensor.  If the tensor is
            a scalar of non-boolean, the scalar is converted to a boolean
            according to the following rule: if the scalar is a numerical
            value, non-zero means True and zero means False; if the scalar is
            a string, non-empty means True and empty means False. If the
            tensor is not a scalar, non-emptiness means True and False
            otherwise.
    body: A function decorated with @Defun.
            A function that takes a list of tensors and returns another
            list of tensors. Both lists have the same types as specified
            by T.
    output_shapes: An optional list of shapes (each a `tf.TensorShape` or list of `ints`). Defaults to `[]`.
    parallel_iterations: An optional `int`. Defaults to `10`.
    name: A name for the operation (optional).

  Returns:
    A list of `Tensor` objects. Has the same type as `input`.
  Whiler   r   r   r   Nr   AExpected list for 'output_shapes' argument to 'while' Op, not %r.r   r   r   )r"   r   r#   r$   r   r%   r&   r'   r(   r)   r*   _while_eager_fallbackr,   r-   r.   r/   r0   r1   r3   r   r4   r5   r6   r7   r   r8   r9   r   s                   rF   _whiler     s"   2 
			0h..0$#\\	11gtUFD&$(=g n M	MD%=	1
	 -	./ / GTT8&&r?;T-T  ))*=?TU'88u4d,%8tE!QX QK'	J""$3<<$fcll6.BFll6"Oll?+-B 568F ::Lvw0	.I && -
##At,,## 
"
d]1$H H ## 
 Us6    !F G9G	F00G	G	G G65G6zraw_ops.Whilec           
         |g }t        |t        t        f      st        d|z        |D cg c]  }t	        j
                  |d       }}|d}t	        j                  |d      }t	        j                  | |      \  }} t        |       }	d|d|d|d|d|f
}
t	        j                  dt        |       |	|
||	      }t	        j                         rt	        j                  d
|	|
|       |S c c}w )Nr   r   r   r   r   r   r   s   WhilerI   r   r   r   s               rF   r   r     s   M	MD%=	1
	 -	./ / GTT8&&r?;T-T  ))*=?TU::5#F.'5e,&$o&(;=&Xs5z,#)s?'""$vw0	. Ur   )N)r   r   r   N)X__doc__collectionstensorflow.pythonr   tensorflow.python.eagerr   r"   r   r&   r   r1   tensorflow.python.frameworkr   rN   tensorflow.security.fuzzing.pyr   _atypesr	   _op_def_registryr
   r(   r   r4   "tensorflow.python.util.deprecationr   tensorflow.python.utilr   	_dispatch tensorflow.python.util.tf_exportr   typingr   r   r   typing_extensionsr   Int32rG   	to_raw_opr   r+   r[   rV   rY   r^   r   r   r   r   r   r   r   r   r   r   strr   r   r   Stringr   r   r   r   r   r   r   r   r   r   r   r   r   intr   r   r   r   r   r   r   Boolr   r   r   r   r   r    r   rF   <module>r     s  
  6 7 1 7 9 F K 3 I C 8 6 % % '[]dh Sygmm!34 Sj !y !56iW]]0B&C <.YsGMM7I-J .` /i-.~t~~l/KLIc7==FX<Y "   H
 -( -yN`I`?a -^ +I)*>4>>*+EF	%7 iX[]oXoNp 1	#w}},- 1iW]]@R6S 1\efikrkxkxfx\y 1f i~t~~d34ygmm);< YsT[TaTaOaEb ktux  {B  {H  {H  vH  lI    z	`bim Ii[() IV Y|^T^^C01YsK'78 6E3 E EVY EN 7)56~t~~FV7WX3 c be 80	#w~~"56 0d -Y+,^T^^K-HI
ygnn1D'E $EC E E_b EN G)$EF~t~~VoGpq C WZ kn 8 fhnr T3+=!> Tl 3	12>4>>.3QR	#w}}:L0M <   L
 rt{ Ky&:!:; KZ /i-.~t~~l/KLi5I0I&J 6 68QSZ^ GS GR 534^T^^O5TUZ] 0>@ 9978HY9Z[ $   z	19S+-. 1iW\\HY>Z 1f 
%#	$^T^^G%<	=
)C,<"= 
YWZ\c\h\hWhMi 
 -/QU FC FP 	#	/">4>>&#9:QT r   