U
    <cn                     @   sX   d dl mZ d dlmZ d dlmZ d dlmZ dd Zdd Z	dee
 dddZd
S )    )Optional)NodeDef)	AttrValueTensorShapeProtoc                 C   sN   i }|dk	r"t |jddd|d< |dk	rJt|}t t j|gdd|d< |S )	a  Creates a dict of objects matching
    https://github.com/tensorflow/tensorboard/blob/master/tensorboard/compat/proto/attr_value.proto
    specifically designed for a NodeDef. The values have been
    reverse engineered from standard TensorBoard logged data.
    Nutf_8encoding)sattrshape)listZ_output_shapes)r   encodetensor_shape_protoZ	ListValue)dtyper   r
   r   Z
shapeproto r   H/tmp/pip-unpacked-wheel-gikjz4vx/torch/utils/tensorboard/_proto_graph.pyattr_value_proto   s    r   c                 C   s   t dd | D dS )zCreates an object matching
    https://github.com/tensorflow/tensorboard/blob/master/tensorboard/compat/proto/tensor_shape.proto
    c                 S   s   g | ]}t j|d qS ))size)r   ZDim).0dr   r   r   
<listcomp>   s     z&tensor_shape_proto.<locals>.<listcomp>)Zdimr   )
outputsizer   r   r   r      s    r   UnSpecifiedN r   c                 C   s<   |dkrg }t |ts|g}t| jdd||t|||dS )zCreates an object matching
    https://github.com/tensorflow/tensorboard/blob/master/tensorboard/compat/proto/node_def.proto
    Nr   r   )nameopinputr   )
isinstancer   r   r   r   )r   r   r   r   r   r   
attributesr   r   r   
node_proto   s    


r!   )r   NNNNr   )typingr   Z%tensorboard.compat.proto.node_def_pb2r   Z'tensorboard.compat.proto.attr_value_pb2r   Z)tensorboard.compat.proto.tensor_shape_pb2r   r   r   tupler!   r   r   r   r   <module>   s   	      