
    AVhh                        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#  ejH                  dg d      Z%dg ddddfde&de&de&de&de&de'de'de'fdZ(  ed       ejR                  e(            Z*de&de&de&de&de&de'de'de'fdZ+dg dddddg dd d!d"dfde&de&de&de&de'de'de'd#e&d$e&d%e&d&e'd'e'd(e,fd)Z-  ed*       ejR                  e-            Z.de&de&de&de&de'de'de'd#e&d$e&d%e&d&e'd'e'd(e,fd+Z/ ed, Z0d;d-e#e!e0f   d.e#e!ejb                  f   d/e#e!ejb                  f   d0e&de'de'd1e#e!e0f   fd2Z2  ed3       ejR                  e2            Z3d-e#e!e0f   d.e#e!ejb                  f   d/e#e!ejb                  f   d0e&de'de'd1e#e!e0f   fd4Z4 ed5 Z5d;d6e#e!e5f   d.e#e!ejb                  f   d7e#e!e5f   d/e#e!ejb                  f   de'de'd1e#e!e5f   fd8Z6  ed9       ejR                  e6            Z7d6e#e!e5f   d.e#e!ejb                  f   d7e#e!e5f   d/e#e!ejb                  f   de'de'd1e#e!e5f   fd:Z8y)<zUPython 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Batch)batched_tensorsbatch_indexid
    num_batch_threadsmax_batch_sizebatch_timeout_microsgrad_timeout_microsmax_enqueued_batches	containershared_namebatching_queuec                    t         j                   xs t        j                         }|j                  }|j                  rB	 t	        j
                  |d|
| d|d|d|d|d|d|d|d	|d
|	      }t        j                  |      }|S t        j                   |d      }t        j                   |d      }t        j                   |d      }t        j                   |d      }|d}t        j                   |d      }|g }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        j0                         rd|j3                  d      d|j3                  d      d|j3                  d      d|j3                  d      d|j5                  d      d|j3                  d      d|j5                  d      d	|j5                  d	      d
|j5                  d
      d|j5                  d      f}|j6                  }t        j8                  d|||       |dt;        |        g|t;        |       d z   }t        j                  |      }|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  Batches all input tensors nondeterministically.

  When many instances of this Op are being run concurrently with the same
  container/shared_name in the same device, some will output zero-shaped Tensors
  and others will output Tensors of size up to max_batch_size.

  All Tensors in in_tensors are batched together (so, for example, labels and
  features should be batched with a single instance of this operation.

  Each invocation of batch emits an `id` scalar which will be used to identify
  this particular invocation when doing unbatch or its gradient.

  Each op which emits a non-empty batch will also emit a non-empty batch_index
  Tensor, which, is a [K, 3] matrix where each row contains the invocation's id,
  start, and length of elements of each set of Tensors present in batched_tensors.

  Batched tensors are concatenated along the first dimension, and all tensors in
  in_tensors must have the first dimension of the same size.

  in_tensors: The tensors to be batched.
  num_batch_threads: Number of scheduling threads for processing batches of work.
   Determines the number of batches processed in parallel.
  max_batch_size: Batch sizes will never be bigger than this.
  batch_timeout_micros: Maximum number of microseconds to wait before outputting
   an incomplete batch.
  allowed_batch_sizes: Optional list of allowed batch sizes. If left empty, does
   nothing. Otherwise, supplies a list of batch sizes, causing the op to pad
   batches up to one of those sizes. The entries must increase monotonically, and
   the final entry must equal max_batch_size.
  grad_timeout_micros: The timeout to use for the gradient. See Unbatch.
  batched_tensors: Either empty tensors or a batch of concatenated Tensors.
  batch_index: If out_tensors is non-empty, has information to invert it.
  container: Controls the scope of sharing of this batch.
  id: always contains a scalar with a unique ID for this invocation of Batch.
  shared_name: Concurrently running instances of batch in the same device with the
   same container and shared_name will batch their elements together. If left
   empty, the op name will be used as the shared name.
  T: the types of tensors to be batched.

  Args:
    in_tensors: A list of `Tensor` objects.
    num_batch_threads: An `int`.
    max_batch_size: An `int`.
    batch_timeout_micros: An `int`.
    grad_timeout_micros: An `int`.
    max_enqueued_batches: An optional `int`. Defaults to `10`.
    allowed_batch_sizes: An optional list of `ints`. Defaults to `[]`.
    container: An optional `string`. Defaults to `""`.
    shared_name: An optional `string`. Defaults to `""`.
    batching_queue: An optional `string`. Defaults to `""`.
    name: A name for the operation (optional).

  Returns:
    A tuple of `Tensor` objects (batched_tensors, batch_index, id).

    batched_tensors: A list of `Tensor` objects. Has the same type as `in_tensors`.
    batch_index: A `Tensor` of type `int64`.
    id: A `Tensor` of type `int64`.
  r   r   r   r   r   allowed_batch_sizesr   r   r   r    N)r   r   r   r   r"   r   r   r   r    namectxr   GExpected list for 'allowed_batch_sizes' argument to 'batch' Op, not %r.r   )
in_tensorsr   r   r   r   r   r"   r   r   r    r#   T)_contextr   _thread_local_datais_eagerr   TFE_Py_FastPathExecute_BatchOutput_make_core_NotOkStatusException_opsraise_from_not_ok_status_FallbackExceptionbatch_eager_fallback_SymbolicException_executemake_int
isinstancelisttuple	TypeErrormake_str_op_def_library_apply_op_helpermust_record_gradient_get_attr_intget_attrinputsrecord_gradientlen)r&   r   r   r   r   r   r"   r   r   r    r#   _ctxtld_resulte_i__op_outputs_attrs_inputs_flats                        S/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/ops/gen_batch_ops.pybatchrO      s   x 
			0h..0$#\\11gtZ)<+^ 46L35H2K{$4nFg ""7+gn$ ''(9;NO$$^5EF.!**+?AWX ))*=?TU!!**+?AWX 	'$	7
	 3	45 5 Qdd"**2/DEddI	;7)K!!+}=+N$$^5EF.'88J:K .&:%8&:%8I(!QX QK'""$!3#4#45H#I 1 12B C$ 67$ 67#S\\2G%H#S%6%67L%M3<<4mll=)+;ll+,c3<<3D
FF ::Lvw0%c*o&''#j/2B*CC'w''	.G && -
##At,,## 
!
(9'3311Y!.t  ## 
  es7    A K ML#K>>LLL2 2M	M	zraw_ops.Batchc                    t        j                  |d      }t        j                  |d      }t        j                  |d      }t        j                  |d      }|d}t        j                  |d      }|g }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|d
|d|d|	d|f}t        j                  dt        |       dz   ||||
      }t        j                         rt        j                  d|||       |d t        |        g|t        |       d  z   }t        j                  |      }|S c c}w )Nr   r   r   r   r   r   r%   r"   r   r   r   r    r'   s   Batch   rA   attrsr$   r#   r   )r5   r6   r7   r8   r9   r:   r;   convert_to_mixed_eager_tensorsr   rC   r>   rB   r,   r-   )r&   r   r   r   r   r   r"   r   r   r    r#   r$   rH   _attr_TrM   rL   rF   s                    rN   r3   r3      s   ''(9;NO$$^5EF.!**+?AWX ))*=?TU!!**+?AWX 	'$	7
	 3	45 5 Qdd"**2/DEddI	;7)K!!+}=+N$$^5EF. ??
CP':j!,!24D(*>.0E,.Ay-6F#w & Xs:':$0C"&(' ""$vw0%c*o&''#j/2B*CC'w''	.5 es   G(low_priority_padding_with_max_batch_sizePAD_UPFlow_priority_max_batch_size!low_priority_batch_timeout_micros!low_priority_max_enqueued_batchesmixed_priority_policybatch_padding_policyenable_large_batch_splittingc                 
   t         j                   xs t        j                         }|j                  }|j                  rd	 t	        j
                  g |d|| |d|d|d|d|d|d|d|	d	|
d
|d|d|d|d|d|d|d|d| }|S t        j                  |d      }t        j                  |d      }t        j                  |d      }t        |t         t"        f      st%        d|z        |D cg c]  }t        j&                  |d       }}|d}t        j                  |d      }|g }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
      }|d}t        j                  |d      }|d}t        j                  |d      }|g }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      }|d}t        j*                  |d      }t-        j.                  	 d#i d| d |d|d|d|d|d|d|d|d|	d	|
d
|d|d|d|d|d|d|d|d|\  }}}}|dd }t        j0                         rg d|j3                  d      d|j5                  d      d|j5                  d      d|j5                  d      d|j5                  d      d|j3                  d      d|j3                  d      d	|j3                  d	      d
|j3                  d
      d|j5                  d      d|j5                  d      d|j3                  d      d|j5                  d      d|j3                  d      d|j3                  d      d!|j3                  d!      d"|j3                  d"      d|j3                  d      d|j7                  d      }|j8                  }t        j:                  d|||       |S # t        j                  $ r }t        j                  ||       Y d}~nd}~wt        j                  $ r Y nw xY w	 t        | |fi d|d|d|d|d|d|d|	d	|
d
|d|d|d|d|d|d|d|d|d|d|S # t        j                  $ r Y w xY wc c}w c c}w c c}w )$a  Batches all the inputs tensors to the computation done by the function.

  So, for example, in the following code

    ```python

    # This input will be captured.
    y = tf.placeholder_with_default(1.0, shape=[])

    @tf.Defun(tf.float32)
    def computation(a):
      return tf.matmul(a, a) + y

    b = gen_batch_ops.batch_function(
            f=computation
            in_tensors=[a],
            captured_tensors=computation.captured_inputs,
            Tout=[o.type for o in computation.definition.signature.output_arg],
            num_batch_threads=1,
            max_batch_size=10,
            batch_timeout_micros=100000,  # 100ms
            allowed_batch_sizes=[3, 10],
            batching_queue="")
    ```

  If more than one session.run call is simultaneously trying to compute `b`
  the values of `a` will be gathered, non-deterministically concatenated
  along the first axis, and only one thread will run the computation.

  Assumes that all arguments of the function are Tensors which will be batched
  along their first dimension.

  Arguments that are captured, are not batched. The session.run call which does
  the concatenation, will use the values of the captured tensors available to it.
  Therefore, typical uses of captured tensors should involve values which remain
  unchanged across session.run calls. Inference is a good example of this.

  SparseTensor is not supported. The return value of the decorated function
  must be a Tensor or a list/tuple of Tensors.

  Args:
    in_tensors: A list of `Tensor` objects. The tensors to be batched.
    captured_tensors: A list of `Tensor` objects.
      The tensors which are captured in the function, and don't need
      to be batched.
    f: A function decorated with @Defun.
    num_batch_threads: An `int`.
      Number of scheduling threads for processing batches of work.
      Determines the number of batches processed in parallel.
    max_batch_size: An `int`. Batch sizes will never be bigger than this.
    batch_timeout_micros: An `int`.
      Maximum number of microseconds to wait before outputting
      an incomplete batch.
    Tout: A list of `tf.DTypes` that has length `>= 1`.
      the types of the output tensors.
    max_enqueued_batches: An optional `int`. Defaults to `10`.
      Maximum number of batches enqueued. Default: 10.
    allowed_batch_sizes: An optional list of `ints`. Defaults to `[]`.
      Optional list of allowed batch sizes. If left empty, does
      nothing. Otherwise, supplies a list of batch sizes, causing the op to pad
      batches up to one of those sizes. The entries must increase monotonically.
      If enable_large_batch_splitting is false (i.e., large-input-split is not
      enabled) the final entry must equal max_batch_size.
    container: An optional `string`. Defaults to `""`.
      Controls the scope of sharing of this batch.
    shared_name: An optional `string`. Defaults to `""`.
      Concurrently running instances of batch in the same device with the
      same container and shared_name will batch their elements together. If left
      empty, the op name will be used as the shared name.
    batching_queue: An optional `string`. Defaults to `""`.
    low_priority_max_batch_size: An optional `int`. Defaults to `0`.
    low_priority_batch_timeout_micros: An optional `int`. Defaults to `0`.
    low_priority_allowed_batch_sizes: An optional list of `ints`. Defaults to `[]`.
    low_priority_max_enqueued_batches: An optional `int`. Defaults to `0`.
    mixed_priority_policy: An optional `string` from: `"low_priority_padding_with_max_batch_size", "low_priority_padding_with_next_allowed_batch_size", "priority_isolation", "priority_merge"`. Defaults to `"low_priority_padding_with_max_batch_size"`.
    batch_padding_policy: An optional `string` from: `"PAD_UP", "BATCH_DOWN", "MINIMIZE_TPU_COST_PER_REQUEST"`. Defaults to `"PAD_UP"`.
    enable_large_batch_splitting: An optional `bool`. Defaults to `False`.
      input with a large size (i.e., larger than the largest value of
      `allowed_batch_sizes`) will be splitted into multiple batches with batch size.
    name: A name for the operation (optional).

  Returns:
    A list of `Tensor` objects of type `Tout`.
  BatchFunctionfr   r   r   r   r"   r   r   r    rX   rY    low_priority_allowed_batch_sizesrZ   r[   r\   Toutr]   Nr#   r$   AExpected list for 'Tout' argument to 'batch_function' Op, not %r.r   PExpected list for 'allowed_batch_sizes' argument to 'batch_function' Op, not %r.r   r   ]Expected list for 'low_priority_allowed_batch_sizes' argument to 'batch_function' Op, not %r.rV   rW   Fr&   captured_tensorsTin	Tcaptured)r_   )r(   r   r)   r*   r   r+   r.   r/   r0   r1   r2   batch_function_eager_fallbackr4   r5   r6   r7   r8   r9   r:   	make_typer;   	make_boolr<   r=   r>   r@   r?   _get_attr_boolrA   rB   )r&   rf   r`   r   r   r   rb   r   r"   r   r   r    rX   rY   ra   rZ   r[   r\   r]   r#   rD   rE   rF   rG   _trH   rI   rJ   rK   rL   rM   s                                  rN   batch_functionrn      s	   j 
			0h..0$#\\11 &&&#&%/&1A&CF&HI&&.&0@& 	& /& 1E& 		& !5	& 7L	&
 	&
 )&
 +4&
 6C& 	& && (6& 	&& (C& 	,& 	*& ,N& 	)& +N& 	*& ,C& 	&  6& 8L& 	& & 5& 	%&g n0 ''(9;NO$$^5EF.!**+?AWX	D4-	(
	')-	./ / 48	8R(

R
(	8$	8!!**+?AWX 	'$	7
	')<	=> > Qdd"**2/DEddI	;7)K!!+}=+N$$^5EF. ("# ( 1 12MOl m&.()%&.&7&78Y[~&#%-')$	4tUm	D
	')I	JK K kK  &Ldfh&7&7<^&_  &L"  &L&.()%&.&7&78Y[~&#"F"++,ACZ[!#!**+?AWX!)#( !)!3!34PRp!q'88$$.$*:$>?$ ,=$ )7	$
 /C$
 JN$ /C$ .A$ $-$ ;F$ )7$ 6Q$ <]$ ;[$ <]$ 0E$ /C$  7S!$" ##$!QX$ QK'""$Bc B3<<$ B&9 B 34B6FB 01B3IB  67B %	B
  67B $B &)\\2G%HB B <<4B 7DB ll=)B ,<B ll+,B /LB  =>B 2B  CDB 1B ll=>B 2B   CD!B" &#B" (+||4K'L#B$ %%B$ '*ll3I&J%B& 'B& \\%('B& +6'B( ll;')B( *0)B( 25f1E)B* -+B,   !?@-BF. ::Lvw8	.s && -
##At,,## 
*
&*+->L  4  4	
 2
 >G " 3A 'B -N ,L -N !6  4 ;? (D    ## 
 
9 e, &LsD    A"S U02U5?U:TS55TTAU U-,U-zraw_ops.BatchFunctionc                 :   t        j                  |d      }t        j                  |d      }t        j                  |d      }t        |t        t        f      st        d|z        |D cg c]  }t        j                  |d       }}|d}t        j                  |d      }|g }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      }|d}t        j                  |d      }|d}t        j                  |d      }|g }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      }|d}t        j                  |d      }t        j                  | |      \  }} t        j                  ||      \  }}t        |       t        |      z   }g d|d|d|d|d|d	|d|	d|
d|d|d|d|d|d|d|d|d|d|d|}t        j                  dt        |      ||||      }t        j                         rt        j                  d|||       |S c c}w c c}w c c}w ) Nr   r   r   rc   rb   r   r   rd   r"   r   r   r   r    r   rX   rY   re   ra   rZ   rV   r[   rW   r\   Fr]   r`   rg   rh   s   BatchFunctionrR   r_   )r5   r6   r7   r8   r9   r:   rj   r;   rk   rT   r   rC   r>   rB   )r&   rf   r`   r   r   r   rb   r   r"   r   r   r    rX   rY   ra   rZ   r[   r\   r]   r#   r$   rm   rH   	_attr_Tin_attr_TcapturedrM   rL   rF   s                               rN   ri   ri     s   ''(9;NO$$^5EF.!**+?AWX	D4-	(
	')-	./ / 48	8R(

R
(	8$	8!!**+?AWX 	'$	7
	')<	=> > Qdd"**2/DEddI	;7)K!!+}=+N$$^5EF. ("# ( 1 12MOl m&.()%&.&7&78Y[~&#%-')$	4tUm	D
	')I	JK K kK  &Ldfh&7&7<^&_  &L"  &L&.()%&.&7&78Y[~&#"F"++,ACZ[!#!**+?AWX!)#( !)!3!34PRp!q"AA*cR)Z&.&M&MN^`c&d#/#j!D)9$::,@C @ @' @): @<L @@(@*>@@.@0E@ @ #@ %.@ 0=@ ?J@ 	@ #	@ %B	@
 @
  C@ $@ &H@ #@ %H@ $@ &=@ @ 0@ 2F@ HM@ @ @ *@ ,2@ 48@ !@ #?@& -s4y#)s?'""$vw8	.C 
9 e, &Ls   +LLL) TV_Unbatch_T_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batched_tensorr   r   timeout_microsreturnc                    t         j                   xs t        j                         }|j                  }|j                  r#	 t	        j
                  |d|| ||d|d|d|      }	|	S t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }t!        j"                  d| ||||||      \  }}}}|dd }	t        j$                         rjd|j'                  d      d|j)                  d      d|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 iw xY w)
a  Reverses the operation of Batch for a single output Tensor.

  An instance of Unbatch either receives an empty batched_tensor, in which case it
  asynchronously waits until the values become available from a concurrently
  running instance of Unbatch with the same container and shared_name, or receives
  a non-empty batched_tensor in which case it finalizes all other concurrently
  running instances and outputs its own element from the batch.

  batched_tensor: The possibly transformed output of Batch. The size of the first
   dimension should remain unchanged by the transformations for the operation to
   work.
  batch_index: The matching batch_index obtained from Batch.
  id: The id scalar emitted by Batch.
  unbatched_tensor: The Tensor corresponding to this execution.
  timeout_micros: Maximum amount of time (in microseconds) to wait to receive the
   batched input tensor associated with a given invocation of the op.
  container: Container to control resource sharing.
  shared_name: Instances of Unbatch with the same container and shared_name are
   assumed to possibly belong to the same batch. If left empty, the op name will
   be used as the shared name.

  Args:
    batched_tensor: A `Tensor`.
    batch_index: A `Tensor` of type `int64`.
    id: A `Tensor` of type `int64`.
    timeout_micros: An `int`.
    container: An optional `string`. Defaults to `""`.
    shared_name: An optional `string`. Defaults to `""`.
    name: A name for the operation (optional).

  Returns:
    A `Tensor`. Has the same type as `batched_tensor`.
  Unbatchr   r   r   N)r   r   r   r#   r$   r   )r   r   r   r   r   r   r#   r'   )r(   r   r)   r*   r   r+   r.   r/   r0   r1   r2   unbatch_eager_fallbackr4   r5   r6   r;   r<   r=   r>   r?   r@   _get_attr_typerA   rB   )r   r   r   r   r   r   r#   rD   rE   rF   rG   rI   rJ   rK   rL   rM   s                   rN   unbatchr     s   D 
			0h..0$#\\	11i~{B.+y{$g n $$^5EF.I	;7)K!!+}=+'88.k9*7!QX QK'""$ 1 12B C3<<4mll=)30B0B30GIF ::L<2('	.? && -
##At,,## 
#
+r.;TtM M ## 
s0    !E F*FFF"F5 5GGzraw_ops.Unbatchc                    t        j                  |d      }|d}t        j                  |d      }|d}t        j                  |d      }t        j                  | g|g       \  }\  } t	        j
                  |t        j                        }t	        j
                  |t        j                        }| ||g}	d|d|d|d|f}
t        j                  dd|	|
||      }t        j                         rt        j                  d	|	|
|       |\  }|S )
Nr   r   r   r   r'   s   Unbatch   rR   r   )r5   r6   r;   args_to_matching_eagerr0   convert_to_tensor_dtypesint64r   r>   rB   )r   r   r   r   r   r   r#   r$   rU   rM   rL   rF   s               rN   r   r   ]  s   $$^5EF.I	;7)K!!+}=+'>>?OQTVXY'N&&{GMMB+b'--0" +r2,nk9c7,&Z<v!$41'""$<2('	.    ) TV_UnbatchGrad_Trs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   original_inputgradc                 N   t         j                   xs t        j                         }|j                  }|j                  r"	 t	        j
                  |d|| |||d|d|      }	|	S |d}t        j                  |d      }|d}t        j                  |d      }t        j                   d| ||||||      \  }}}}|dd }	t        j"                         rYd|j%                  d      d|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 Bw xY w)	a  Gradient of Unbatch.

  Acts like Batch but using the given batch_index index of batching things as they
  become available. This ensures that the gradients are propagated back in the
  same session which did the forward pass.

  original_input: The input to the Unbatch operation this is the gradient of.
  batch_index: The batch_index given to the Unbatch operation this is the gradient
  of.
  grad: The downstream gradient.
  id: The id scalar emitted by Batch.
  batched_grad: The return value, either an empty tensor or the batched gradient.
  container: Container to control resource sharing.
  shared_name: Instances of UnbatchGrad with the same container and shared_name
   are assumed to possibly belong to the same batch. If left empty, the op name
   will be used as the shared name.

  Args:
    original_input: A `Tensor`.
    batch_index: A `Tensor` of type `int64`.
    grad: A `Tensor`. Must have the same type as `original_input`.
    id: A `Tensor` of type `int64`.
    container: An optional `string`. Defaults to `""`.
    shared_name: An optional `string`. Defaults to `""`.
    name: A name for the operation (optional).

  Returns:
    A `Tensor`. Has the same type as `original_input`.
  UnbatchGradr   r   N)r   r   r#   r$   r   )r   r   r   r   r   r   r#   r'   )r(   r   r)   r*   r   r+   r.   r/   r0   r1   r2   unbatch_grad_eager_fallbackr4   r5   r;   r<   r=   r>   r@   r   rA   rB   )r   r   r   r   r   r   r#   rD   rE   rF   rG   rI   rJ   rK   rL   rM   s                   rN   unbatch_gradr   v  s   < 
			0h..0$#\\11mT>;bY{<g n I	;7)K!!+}=+'88n+ R9#.T;!QX QK'""$3<<4mll=)30B0B30GIF::L|VW6('	.; && -
##At,,## 
(
+tR9!$8 8 ## 
s0     D/ /E6EE65E6:F F$#F$zraw_ops.UnbatchGradc                    |d}t        j                  |d      }|d}t        j                  |d      }t        j                  | |g|g       \  }}	|	\  } }t        j                  |t
        j                        }t        j                  |t
        j                        }| |||g}
d|d|d|f}t        j                  dd|
|||      }t        j                         rt        j                  d|
||       |\  }|S )	Nr   r   r   r'   s   UnbatchGradr   rR   r   )
r5   r;   r   r0   r   r   r   r   r>   rB   )r   r   r   r   r   r   r#   r$   rU   	_inputs_TrM   rL   rF   s                rN   r   r     s    I	;7)K!!+}=+667MsTVW'9$>4&&{GMMB+b'--0" +tR8,M;WM&^Q|#)s?'""$|VW6('	.r   )r   r   N)9__doc__collectionstensorflow.pythonr   tensorflow.python.eagerr   r(   r   r.   r   r5   tensorflow.python.frameworkr   r   tensorflow.security.fuzzing.pyr   _atypesr	   _op_def_registryr
   r0   r   r<   "tensorflow.python.util.deprecationr   tensorflow.python.utilr   	_dispatch tensorflow.python.util.tf_exportr   typingr   r   r   typing_extensionsr   
namedtupler,   intstrrO   	to_raw_opr   r3   boolrn   r_   ri   rr   Int64r   r   r   r   r   r   r    r   rN   <module>r      sv  
  6 7 1 7 9 F K 3 I C 8 6 % % '%{%%,.
 RT  jl  |~  PR  gi  pt L Lc LY\ Lsv L  NQ L  x{ L  LO L  cf L\ 	#	/">4>>%#89( (S (hk (  CF (  ^a (  CF (  UX (  jm (V \^  tv  FH  Z\  qs  UV  ~  bd  LM  iS  nv  Z_  fj bs b\_ bwz b  X[ b  BE b  VY b  mp b  QT b  z} b  HK b  eh b  jm b  UY bH 3	12>4>>.3QRIVY Ikn I  GJ I  hk I  MP I  _b I  tw I  VY I  ~A I  HK I  dg I  B I  bf IX   |	JIc<&78 JyQTV]VcVcQcGd Jjstw  zA  zG  zG  uG  kH J  Z] J  il J  }@ J  S\  ]`  bn  ]n  So JX ')%
&~t~~g'>
?9S,5F+G V_`celerer`rVs   zC  DG  IP  IV  IV  DV  zW   il   y|   KN   ^g  hk  my  hy  ^z .   D
 C30@+@!A CPYZ]_f_l_lZlPm Cu~  @C  EU  @U  vV C  \e  fi  kr  kx  kx  fx  \y C  EH C  Y\ C  ox  y|  ~N  yN  oO CJ /i-.~t~~l/KL	#?O:O0P _hilnun{n{i{_|   EN  OR  Td  Od  Ee   kt  ux  zA  zG  zG  uG  kH   UX   gj   zC  DG  IY  DY  zZ r   