o
    œýi—  ã                   @   sD   d Z ddlZddlZdZe dddg¡Zdd„ Zd	d
„ Zdd„ ZdS )z2Common values and methods for TensorFlow Debugger.é    Nzgrpc://ÚRunKeyÚ
feed_namesÚfetch_namesc                 C   s   t | dƒr| jS t| ƒS )a±  Obtain the name or string representation of a graph element.

  If the graph element has the attribute "name", return name. Otherwise, return
  a __str__ representation of the graph element. Certain graph elements, such as
  `SparseTensor`s, do not have the attribute "name".

  Args:
    elem: The graph element in question.

  Returns:
    If the attribute 'name' is available, return the name. Otherwise, return
    str(fetch).
  Úname)Úhasattrr   Ústr)Úelem© r	   úX/mnt/sdb/aimis/docanh/lib/python3.10/site-packages/tensorflow/python/debug/lib/common.pyÚget_graph_element_name   s   r   c                 C   sj   g }t | ttfƒr| D ]	}| t|ƒ¡ q|S t | tƒr,| D ]}| t| | ƒ¡ q|S | t| ƒ¡ |S )a~  Get a flattened list of the names in run() call feeds or fetches.

  Args:
    feeds_or_fetches: Feeds or fetches of the `Session.run()` call. It maybe
      a Tensor, an Operation or a Variable. It may also be nested lists, tuples
      or dicts. See doc of `Session.run()` for more details.

  Returns:
    (list of str) A flattened list of fetch names from `feeds_or_fetches`.
  )Ú
isinstanceÚlistÚtupleÚextendÚget_flattened_namesÚdictÚappendr   )Úfeeds_or_fetchesÚlinesÚitemÚkeyr	   r	   r
   r   +   s   	
øþr   c                 C   s   t  tt| ƒt|ƒƒ¡S )a†  Summarize the names of feeds and fetches as a RunKey JSON string.

  Args:
    feed_dict: The feed_dict given to the `Session.run()` call.
    fetches: The fetches from the `Session.run()` call.

  Returns:
    A JSON Array consisting of two items. They first items is a flattened
    Array of the names of the feeds. The second item is a flattened Array of
    the names of the fetches.
  )ÚjsonÚdumpsr   r   )Ú	feed_dictÚfetchesr	   r	   r
   Úget_run_keyF   s   ÿr   )	Ú__doc__Úcollectionsr   ÚGRPC_URL_PREFIXÚ
namedtupler   r   r   r   r	   r	   r	   r
   Ú<module>   s   