class_docstr: Exposes a Python policy as wrapper over a TF Policy.
class_docstr_tok: ["Exposes","a","Python","policy","as","wrapper","over","a","TF","Policy","."]
docstr: Restores the policy from the checkpoint.
  
  Args:
    policy_dir: Directory with the checkpoint.
    graph: A graph, inside which policy the is restored (optional).
    assert_consumed: If true, contents of the checkpoint will be checked for a
      match against graph variables.
  
  Returns:
    step: Global step associated with the restored policy checkpoint.
  
  Raises:
    RuntimeError: if the policy is not initialized.
    AssertionError: if the checkpoint contains variables which do not have
      matching names in the graph, and assert_consumed is set to True.
docstr_tok: ["Restores","the","policy","from","the","checkpoint",".","Args",":","policy_dir",":","Directory","with","the","checkpoint",".","graph",":","A","graph",",","inside","which","policy","the","is","restored","(","optional",")",".","assert_consumed",":","If","true",",","contents","of","the","checkpoint","will","be","checked","for","a","match","against","graph","variables",".","Returns",":","step",":","Global","step","associated","with","the","restored","policy","checkpoint",".","Raises",":","RuntimeError",":","if","the","policy","is","not","initialized",".","AssertionError",":","if","the","checkpoint","contains","variables","which","do","not","have","matching","names","in","the","graph",",","and","assert_consumed","is","set","to","True","."]
code: def restore(
      self,
      policy_dir: Text,
      graph: Optional[tf.Graph] = None,
      assert_consumed: bool = True,
  ):
      """Restores the policy from the checkpoint.
  
      Args:
        policy_dir: Directory with the checkpoint.
        graph: A graph, inside which policy the is restored (optional).
        assert_consumed: If true, contents of the checkpoint will be checked for a
          match against graph variables.
  
      Returns:
        step: Global step associated with the restored policy checkpoint.
  
      Raises:
        RuntimeError: if the policy is not initialized.
        AssertionError: if the checkpoint contains variables which do not have
          matching names in the graph, and assert_consumed is set to True.
      """
  
      if not self._built:
          raise RuntimeError(
              "PyTFPolicy must be initialized before being restored."
          )
      if not graph:
          graph = tf.compat.v1.get_default_graph()
  
      with graph.as_default():
          global_step = tf.compat.v1.train.get_or_create_global_step()
          policy_checkpointer = common.Checkpointer(
              ckpt_dir=policy_dir,
              policy=self._tf_policy,
              global_step=global_step,
          )
          status = policy_checkpointer.initialize_or_restore(
              self.session
          )
          with self.session.as_default():
              if assert_consumed:
                  status.assert_consumed()
              status.run_restore_ops()
          return self.session.run(global_step)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Optional, Text
  from absl import logging
  import tensorflow
  from tf_agents.policies import py_policy
  from tf_agents.policies import tf_policy
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import policy_step
  from tf_agents.trajectories import time_step
  from tf_agents.typing import types
  from tf_agents.utils import common
  from tf_agents.utils import nest_utils
  from tf_agents.utils import session_utils
label_desc: Use image node_id 5 for calling the PyTFPolicy obj's underlying member method code with example usage: obj.restore(policy_dir, graph, assert_consumed) and returns: self