parameters: (save_path)
return_statement: return graph
docstring: r"""Visualizes an object-based checkpoint (from `tf.train.Checkpoint`).
  
    Useful for inspecting checkpoints and debugging loading issues.
  
    Example usage from Python (requires pydot):
    ```python
    import tensorflow as tf
    import pydot
  
    dot_string = tf.contrib.checkpoint.dot_graph_from_checkpoint('/path/to/ckpt')
    parsed, = pydot.graph_from_dot_data(dot_string)
    parsed.write_svg('/tmp/tensorflow/visualized_checkpoint.svg')
    ```
  
    Example command line usage:
    ```sh
    python -c "import tensorflow as tf;\
      print(tf.contrib.checkpoint.dot_graph_from_checkpoint('/path/to/ckpt'))"\
      | dot -Tsvg > /tmp/tensorflow/checkpoint_viz.svg
    ```
  
    Args:
      save_path: The checkpoint prefix, as returned by `tf.train.Checkpoint.save`
        or `tf.train.latest_checkpoint`.
    Returns:
      A graph in DOT format as a string.
docstring_summary: r"""Visualizes an object-based checkpoint (from `tf.train.Checkpoint`).
docstring_tokens: r Visualizes an object - based checkpoint ( from tf . train . Checkpoint ) .
function: def dot_graph_from_checkpoint(save_path):
    r"""Visualizes an object-based checkpoint (from `tf.train.Checkpoint`).
  
    Useful for inspecting checkpoints and debugging loading issues.
  
    Example usage from Python (requires pydot):
    ```python
    import tensorflow as tf
    import pydot
  
    dot_string = tf.contrib.checkpoint.dot_graph_from_checkpoint('/path/to/ckpt')
    parsed, = pydot.graph_from_dot_data(dot_string)
    parsed.write_svg('/tmp/tensorflow/visualized_checkpoint.svg')
    ```
  
    Example command line usage:
    ```sh
    python -c "import tensorflow as tf;\
      print(tf.contrib.checkpoint.dot_graph_from_checkpoint('/path/to/ckpt'))"\
      | dot -Tsvg > /tmp/tensorflow/checkpoint_viz.svg
    ```
  
    Args:
      save_path: The checkpoint prefix, as returned by `tf.train.Checkpoint.save`
        or `tf.train.latest_checkpoint`.
    Returns:
      A graph in DOT format as a string.
    """
    reader = pywrap_tensorflow.NewCheckpointReader(save_path)
    object_graph = trackable_utils.object_metadata(save_path)
    shape_map = reader.get_variable_to_shape_map()
    dtype_map = reader.get_variable_to_dtype_map()
    graph = 'digraph {\n'
    def _escape(name):
      return name.replace('"', '\\"')
    slot_ids = set()
    for node in object_graph.nodes:
      for slot_reference in node.slot_variables:
        slot_ids.add(slot_reference.slot_variable_node_id)
    for node_id, node in enumerate(object_graph.nodes):
      if (len(node.attributes) == 1
          and node.attributes[0].name == trackable.VARIABLE_VALUE_KEY):
        if node_id in slot_ids:
          color = 'orange'
          tooltip_prefix = 'Slot variable'
        else:
          color = 'blue'
          tooltip_prefix = 'Variable'
        attribute = node.attributes[0]
        graph += ('N_%d [shape=point label="" color=%s width=.25'
                  ' tooltip="%s %s shape=%s %s"]\n') % (
                      node_id,
                      color,
                      tooltip_prefix,
                      _escape(attribute.full_name),
                      shape_map[attribute.checkpoint_key],
                      dtype_map[attribute.checkpoint_key].name)
      elif node.slot_variables:
        graph += ('N_%d [shape=point label="" width=.25 color=red,'
                  'tooltip="Optimizer"]\n') % node_id
      else:
        graph += 'N_%d [shape=point label="" width=.25]\n' % node_id
      for reference in node.children:
        graph += 'N_%d -> N_%d [label="%s"]\n' % (
            node_id, reference.node_id, _escape(reference.local_name))
      for slot_reference in node.slot_variables:
        graph += 'N_%d -> N_%d [label="%s" style=dotted]\n' % (
            node_id,
            slot_reference.slot_variable_node_id,
            _escape(slot_reference.slot_name))
        graph += 'N_%d -> N_%d [style=dotted]\n' % (
            slot_reference.original_variable_node_id,
            slot_reference.slot_variable_node_id)
    graph += '}\n'
    return graph
function_tokens: def dot_graph_from_checkpoint ( save_path ) : reader = pywrap_tensorflow . NewCheckpointReader ( save_path ) object_graph = trackable_utils . object_metadata ( save_path ) shape_map = reader . get_variable_to_shape_map ( ) dtype_map = reader . get_variable_to_dtype_map ( ) graph = 'digraph {\n' def _escape ( name ) : return name . replace ( '"' , '\\"' ) slot_ids = set ( ) for node in object_graph . nodes : for slot_reference in node . slot_variables : slot_ids . add ( slot_reference . slot_variable_node_id ) for node_id , node in enumerate ( object_graph . nodes ) : if ( len ( node . attributes ) == 1 and node . attributes [ 0 ] . name == trackable . VARIABLE_VALUE_KEY ) : if node_id in slot_ids : color = 'orange' tooltip_prefix = 'Slot variable' else : color = 'blue' tooltip_prefix = 'Variable' attribute = node . attributes [ 0 ] graph += ( 'N_%d [shape=point label="" color=%s width=.25' ' tooltip="%s %s shape=%s %s"]\n' ) % ( node_id , color , tooltip_prefix , _escape ( attribute . full_name ) , shape_map [ attribute . checkpoint_key ] , dtype_map [ attribute . checkpoint_key ] . name ) elif node . slot_variables : graph += ( 'N_%d [shape=point label="" width=.25 color=red,' 'tooltip="Optimizer"]\n' ) % node_id else : graph += 'N_%d [shape=point label="" width=.25]\n' % node_id for reference in node . children : graph += 'N_%d -> N_%d [label="%s"]\n' % ( node_id , reference . node_id , _escape ( reference . local_name ) ) for slot_reference in node . slot_variables : graph += 'N_%d -> N_%d [label="%s" style=dotted]\n' % ( node_id , slot_reference . slot_variable_node_id , _escape ( slot_reference . slot_name ) ) graph += 'N_%d -> N_%d [style=dotted]\n' % ( slot_reference . original_variable_node_id , slot_reference . slot_variable_node_id ) graph += '}\n' return graph