o
    ®Ÿ?e«
  ã                   @   sB   d Z ddlZddlmZ dgZejgZdd„ Zdd„ Zd	d
„ Z	dS )z5Helpers to traverse the Dataset dependency structure.é    N)ÚdtypesZDummyIterationCounterc                 C   sz   g }t  ¡ }| | jj¡ g }| ¡ s;| ¡ }| |¡ ||ƒr%| |¡ |jD ]}|j}||vr6| |¡ q(| ¡ r|S )zBTraverse a dataset graph, returning nodes matching `op_filter_fn`.)	ÚqueueÚQueueÚputZ_variant_tensorÚopÚemptyÚgetÚappendZinputs)ÚdatasetZop_filter_fnÚresultZbfs_qÚvisitedr   ÚiZinput_op© r   úe/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/data/util/traverse.pyÚ	_traverse   s    



€ø	r   c                 C   s   dd„ }t | |ƒS )aH  Given an input dataset, finds all allowlisted ops used for construction.

  Allowlisted ops are stateful ops which are known to be safe to capture by
  value.

  Args:
    dataset: Dataset to find allowlisted stateful ops for.

  Returns:
    A list of variant_tensor producing dataset ops used to construct this
    dataset.
  c                 S   s   | j d jtv p| jtv S ©Nr   )ÚoutputsÚdtypeÚTENSOR_TYPES_ALLOWLISTÚtypeÚOP_TYPES_ALLOWLIST©r   r   r   r   Úcapture_by_value<   s   ÿz5obtain_capture_by_value_ops.<locals>.capture_by_value©r   )r
   r   r   r   r   Úobtain_capture_by_value_ops.   s   
r   c                 C   s   t | dd„ ƒS )a¯  Given an input dataset, finds all dataset ops used for construction.

  A series of transformations would have created this dataset with each
  transformation including zero or more Dataset ops, each producing a dataset
  variant tensor. This method outputs all of them.

  Args:
    dataset: Dataset to find variant tensors for.

  Returns:
    A list of variant_tensor producing dataset ops used to construct this
    dataset.
  c                 S   s   | j d jtjkS r   )r   r   r   Úvariantr   r   r   r   Ú<lambda>Q   s    z/obtain_all_variant_tensor_ops.<locals>.<lambda>r   )r
   r   r   r   Úobtain_all_variant_tensor_opsC   s   r   )
Ú__doc__r   Ztensorflow.python.frameworkr   r   r   r   r   r   r   r   r   r   r   Ú<module>   s   