class_docstr: Class to count number of episodes run by an observer.
class_docstr_tok: ["Class","to","count","number","of","episodes","run","by","an","observer","."]
code: def __call__(self, traj):
      num_episodes = tf.reduce_sum(
          input_tensor=tf.cast(traj.is_boundary(), dtype=tf.int32)
      )
      with tf.control_dependencies(
          [self._num_episodes.assign_add(num_episodes)]
      ):
          return tf.nest.map_structure(tf.identity, traj)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from typing import Any
  import numpy
  import tensorflow
  from tf_agents import specs
  from tf_agents.environments import py_environment
  from tf_agents.policies import py_policy
  from tf_agents.policies import tf_policy
  from tf_agents.replay_buffers import tf_uniform_replay_buffer
  from tf_agents.specs import tensor_spec
  from tf_agents.trajectories import policy_step
  from tf_agents.trajectories import time_step
  from tf_agents.trajectories import trajectory
  from tf_agents.utils import common
label_desc: Use image node_id 4 for calling the NumEpisodesObserver obj's underlying member method code with example usage: obj.__call__(traj) and returns: tf