class_docstr: Specification for a distributed task.
  
  It contains the job name, index of the task,
  the parameter servers and the worker servers. If you want to use the last worker
  for continuous evaluation you can call the method `use_last_worker_as_evaluator`
  which returns a new :class:`TaskSpecDef` object without the last worker in the
  cluster specification.
  
  Parameters
  ----------
  task_type : str
      Task type. One of `master`, `worker` or `ps`.
  index : int
      The zero-based index of the task. Distributed training jobs will have a single
      master task, one or more parameter servers, and one or more workers.
  trial : int
      The identifier of the trial being run.
  ps_hosts : str OR list of str
      A string with a coma separate list of hosts for the parameter servers
      or a list of hosts.
  worker_hosts : str OR list of str
      A string with a coma separate list of hosts for the worker servers
      or a list of hosts.
  master : str
      A string with the master hosts
  
  Notes
  ----------
  master might not be included in TF_CONFIG and can be None. The shard_index is adjusted
  in any case to assign 0 to master and >= 1 to workers.
  This implementation doesn't support sparse arrays in the `TF_CONFIG` variable as the
  official TensorFlow documentation shows, as it is not a supported by the json
  definition.
  
  References
  ----------
  - `ML-engine trainer considerations <https://cloud.google.com/ml-engine/docs/trainer-considerations#use_tf_config>`__
docstr: Returns a new :class:`TaskSpecDef` where the last worker has been removed from
  the list of worker_hosts, so it is not used for training anymore. You can call
  is_evaluator to know whether this server is the evaluator one or not.
  In case there is only one server for training this method raises an exception, as
  you cannot use any server for evaluation.
code: def use_last_worker_as_evaluator(self):
      """Returns a new :class:`TaskSpecDef` where the last worker has been removed from
      the list of worker_hosts, so it is not used for training anymore. You can call
      is_evaluator to know whether this server is the evaluator one or not.
      In case there is only one server for training this method raises an exception, as
      you cannot use any server for evaluation.
  
      """
      if self.num_workers <= 1:
          raise Exception(
              "You need more than one worker instance to use one as evaluator"
          )
  
      return TaskSpecDef(
          task_type=self.type,
          index=self._index,
          trial=self.trial,
          ps_hosts=self.ps_hosts,
          worker_hosts=self.worker_hosts[:-1],
          master=self.master,
      )
  
imports: import json
  import os
  import time
  import tensorflow
  from tensorflow.python.training import session_run_hook
  from tensorlayer import logging
  from tensorlayer.decorators import deprecated
  from tensorlayer.lazy_imports import LazyImport
label_desc: Use image node_id 9 for calling the TaskSpecDef obj's underlying member method code with example usage: obj.use_last_worker_as_evaluator() and returns: TaskSpecDef