o
    ?ep                     @   s   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	 G d	d
 d
e
d
dZdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! ZdS )"z)Operators specific to slicing operations.    N)dtypes)tensor_util)gen_array_ops)gen_string_ops)list_ops)tensor_array_opsc                   @   s   e Zd ZdS )GetItemOptsN)__name__
__module____qualname__ r   r   m/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/autograph/operators/slices.pyr      s    r   element_dtypec                 C   s|   t |tsJ t | tjrt| |S t| r9| jtj	kr#t
| ||S | jtjkr4| jjdkr4t| |S t| |S t| |S )a  The slice read operator (i.e. __getitem__).

  Note: it is unspecified whether target will be mutated or not. In general,
  if target is mutable (like Python lists), it will be mutated.

  Args:
    target: An entity that supports getitem semantics.
    i: Index to read from.
    opts: A GetItemOpts object.

  Returns:
    The read element.

  Raises:
    ValueError: if target is not of a supported type.
  r   )
isinstancer   r   TensorArray_tf_tensorarray_get_itemr   
is_tf_typedtyper   variant_tf_tensor_list_get_itemstringshapeZndims_tf_tensor_string_get_item_tf_tensor_get_item_py_get_item)targetioptsr   r   r   get_item"   s   




r   c                 C   s
   |  |S )z4Overload of get_item that stages a TensorArray read.)readr   r   r   r   r   r   B   s   
r   c                 C   s(   |j du r	tdtj| ||j d}|S )z4Overload of get_item that stages a Tensor list read.Nzacannot retrieve from a list without knowing its element type; use set_element_type to annotate itr   )r   
ValueErrorr   Ztensor_list_get_item)r   r   r   xr   r   r   r   G   s   
r   c                 C      | | S )zAOverload of get_item that stages a Tensor (not Tensor list) read.r   r!   r   r   r   r   P      r   c                 C   s   t | |d}|S )z6Overload of get_item that stages a Tensor string read.   )r   substrr   r   r#   r   r   r   r   U   s   r   c                 C   r$   )z>Overload of get_item that executes a Python list modification.r   r!   r   r   r   r   [   r%   r   c                 C   sR   t | tjrt| ||S t| r#| jtjkrt	| ||S t
| ||S t| ||S )a  The slice write operator (i.e. __setitem__).

  Note: it is unspecified whether target will be mutated or not. In general,
  if target is mutable (like Python lists), it will be mutated.

  Args:
    target: An entity that supports setitem semantics.
    i: Index to modify.
    x: The new element value.

  Returns:
    Same as target, after the update was performed.

  Raises:
    ValueError: if target is not of a supported type.
  )r   r   r   _tf_tensorarray_set_itemr   r   r   r   r   _tf_tensor_list_set_item_tf_tensor_set_item_py_set_itemr(   r   r   r   set_item`   s   
r-   c                 C   s   |  ||S )z5Overload of set_item that stages a TensorArray write.)writer(   r   r   r   r)   |   s   r)   c                 C   s   t | ||S )z6Overload of set_item that stages a Tensor list update.)r   Ztensor_list_set_itemr(   r   r   r   r*      s   r*   c                 C   s   t | |ff|fS )z9Overload of set_item that stages a Tensor scatter update.)r   Ztensor_scatter_updater(   r   r   r   r+      s   r+   c                 C   s   || |< | S )z>Overload of set_item that executes a Python list modification.r   r(   r   r   r   r,      s   r,   )__doc__collectionsZtensorflow.python.frameworkr   r   Ztensorflow.python.opsr   r   r   r   
namedtupler   r   r   r   r   r   r   r-   r)   r*   r+   r,   r   r   r   r   <module>   s(    	