class_docstr: Gathers and serializes a checkpoint view.
  
  This is for loading specific portions of a module from a
  checkpoint, and be able to compare two modules by matching components.
  
  Example usage:
  
  >>> class SimpleModule(tf.Module):
  ...   def __init__(self, name=None):
  ...     super().__init__(name=name)
  ...     self.a_var = tf.Variable(5.0)
  ...     self.b_var = tf.Variable(4.0)
  ...     self.vars = [tf.Variable(1.0), tf.Variable(2.0)]
  
  >>> root = SimpleModule(name="root")
  >>> root.leaf = SimpleModule(name="leaf")
  >>> ckpt = tf.train.Checkpoint(root)
  >>> save_path = ckpt.save('/tmp/tf_ckpts')
  >>> checkpoint_view = tf.train.CheckpointView(save_path)
  
  Pass `node_id=0` to `tf.train.CheckpointView.children()` to get the dictionary
  of all children directly linked to the checkpoint root.
  
  >>> for name, node_id in checkpoint_view.children(0).items():
  ...   print(f"- name: '{name}', node_id: {node_id}")
  - name: 'a_var', node_id: 1
  - name: 'b_var', node_id: 2
  - name: 'vars', node_id: 3
  - name: 'leaf', node_id: 4
  - name: 'root', node_id: 0
  - name: 'save_counter', node_id: 5
class_docstr_tok: ["Gathers","and","serializes","a","checkpoint","view",".","This","is","for","loading","specific","portions","of","a","module","from","a","checkpoint",",","and","be","able","to","compare","two","modules","by","matching","components",".","Example","usage",":",">",">",">","class","SimpleModule","(","tf.Module",")",":","...","def","__init__","(","self",",","name=None",")",":","...","super","(",")",".__init__","(","name=name",")","...","self.a_var","=","tf.Variable","(","5.0",")","...","self.b_var","=","tf.Variable","(","4.0",")","...","self.vars","=","[","tf.Variable","(","1.0",")",",","tf.Variable","(","2.0",")","]",">",">",">","root","=","SimpleModule","(","name=","''","root","''",")",">",">",">","root.leaf","=","SimpleModule","(","name=","''","leaf","''",")",">",">",">","ckpt","=","tf.train.Checkpoint","(","root",")",">",">",">","save_path","=","ckpt.save","(","'\/tmp\/tf_ckpts","'",")",">",">",">","checkpoint_view","=","tf.train.CheckpointView","(","save_path",")","Pass","`","node_id=0","`","to","`","tf.train.CheckpointView.children","(",")","`","to","get","the","dictionary","of","all","children","directly","linked","to","the","checkpoint","root",".",">",">",">","for","name",",","node_id","in","checkpoint_view.children","(","0",")",".items","(",")",":","...","print","(","f","''","-","name",":","'","{","name","}","'",",","node_id",":","{","node_id","}","''",")","-","name",":","'a_var","'",",","node_id",":","1","-","name",":","'b_var","'",",","node_id",":","2","-","name",":","'vars","'",",","node_id",":","3","-","name",":","'leaf","'",",","node_id",":","4","-","name",":","'root","'",",","node_id",":","0","-","name",":","'save_counter","'",",","node_id",":","5"]
docstr: Configure the checkpoint view.
  
  Args:
    save_path: The path to the checkpoint.
  
  Raises:
    ValueError: If the save_path does not lead to a TF2 checkpoint.
docstr_tok: ["Configure","the","checkpoint","view",".","Args",":","save_path",":","The","path","to","the","checkpoint",".","Raises",":","ValueError",":","If","the","save_path","does","not","lead","to","a","TF2","checkpoint","."]
code: def __init__(self, save_path):
      """Configure the checkpoint view.
  
      Args:
        save_path: The path to the checkpoint.
  
      Raises:
        ValueError: If the save_path does not lead to a TF2 checkpoint.
      """
  
      reader = py_checkpoint_reader.NewCheckpointReader(save_path)
      try:
          object_graph_string = reader.get_tensor(
              base.OBJECT_GRAPH_PROTO_KEY
          )
      except errors_impl.NotFoundError as not_found_error:
          raise ValueError(
              f'The specified checkpoint "{save_path}" does not appear to be '
              "object-based (saved with TF2) since it is missing the key "
              f'"{base.OBJECT_GRAPH_PROTO_KEY}". Likely it was created with the '
              "TF1 name-based saver and does not contain an object dependency graph."
          ) from not_found_error
      object_graph_proto = (
          trackable_object_graph_pb2.TrackableObjectGraph()
      )
      object_graph_proto.ParseFromString(object_graph_string)
      self._object_graph_proto = object_graph_proto
  
file_path: tensorflow/tensorflow/python/checkpoint/checkpoint_view.py
imports: import collections
  from tensorflow.core.protobuf import trackable_object_graph_pb2
  from tensorflow.python.checkpoint import trackable_view
  from tensorflow.python.framework import errors_impl
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.trackable import base
  from tensorflow.python.training import py_checkpoint_reader
  from tensorflow.python.util import object_identity
  from tensorflow.python.util.tf_export import tf_export
label_desc: Use image node_id 1 to create a new CheckpointView object from inherited base classes: object with example: obj = CheckpointView(save_path)