
    BVh
                     d    d Z ddlZddlmZ ddlmZ ddlmZ  G d dej                        Z	d Z
y)	zConverter for slice operations.    N)	converter)
directives)	templatesc                   "    e Zd ZdZd Zd Zd Zy)SliceTransformerzConverts slicing operations to their TF counterpart.

  Currently, relying on the default slice operator that Tensor uses is
  insufficient, because TensorArray and tensor lists use dedicated index read
  and write functions.
  c                    t        |t        j                        sy |j                  }t        |t        j                  t        j
                  f      ry d}t        j                  ||j                  |j                  |      S )Nz5
      target = ag__.set_item(target, key, item)
    )targetkeyitem)	
isinstancegast	SubscriptsliceTupleSlicer   replacevalue)selfr	   r   stemplates        ]/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/autograph/converters/slices.py_process_single_assignmentz+SliceTransformer._process_single_assignment    se    fdnn-A!djj$**-.H 6<<eE E    c                     | j                  |      }t        |j                        dk7  rt        d      | j	                  |j                  d   |j
                        }||S |S )N   zmultiple assignmentr   )generic_visitlentargetsNotImplementedErrorr   r   )r   nodereplacements      r   visit_AssignzSliceTransformer.visit_Assign-   s^    d#D
4<<A 56611$,,q/4::NKKr   c                    | j                  |      }|j                  }t        |t        j                  t        j
                  f      r|S t        |j                  t        j                        s|S | j                  |j                  t        j                  dt        j                  d            }d}t        j                  ||j                  ||      S )NdtypeNone)defaultzq
      ag__.get_item(
          target,
          key,
          opts=ag__.GetItemOpts(element_dtype=dtype))
    )r	   r
   r$   )r   r   r   r   r   r   ctxLoadget_definition_directiver   r   set_element_typer   replace_as_expression)r   r    r   r$   r   s        r   visit_Subscriptz SliceTransformer.visit_Subscript7   s    d#D

A!djj$**-.kdhh		* k))

##//7	 * 9EH **%9 9r   N)__name__
__module____qualname____doc__r   r"   r,    r   r   r   r      s    E9r   r   c                 6    t        |      j                  |       S )N)r   visit)r    r'   s     r   	transformr4   R   s    	#		$	$T	**r   )r0   r    tensorflow.python.autograph.corer    tensorflow.python.autograph.langr    tensorflow.python.autograph.pyctr   Baser   r4   r1   r   r   <module>r9      s,    &  6 7 679y~~ 79t+r   