code: def _count_ps(cluster_spec):
      """Counts the number of parameter servers in cluster_spec."""
      if not cluster_spec:
          raise RuntimeError(
              "Internal error: `_count_ps` does not expect empty cluster_spec."
          )
  
      return len(cluster_spec.as_dict().get(PS, []))
  
file_path: tensorflow/tensorflow/python/distribute/estimator_training.py
imports: import copy
  import six
  from tensorflow.python.distribute import distribute_coordinator
  from tensorflow.python.distribute import distribute_coordinator_context
  from tensorflow.python.distribute import multi_worker_util
  from tensorflow.python.platform import tf_logging
  from tensorflow.python.training import server_lib
label_desc: Use image node_id 1 for calling a global function with example usage: _count_ps(cluster_spec) and returns: len