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","."]
code: def save(
      self,
      policy_dir: Optional[Text] = None,
      graph: Optional[tf.Graph] = None,
  ):
      if not self._built:
          raise RuntimeError("PyTFPolicy has not been initialized yet.")
  
      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,
          )
          policy_checkpointer.initialize_or_restore(self.session)
          with self.session.as_default():
              policy_checkpointer.save(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 4 for calling the PyTFPolicy obj's underlying member method code with example usage: obj.save(policy_dir, graph) without return types