class_docstr: The worker context class.
  
  This context object provides configuration information for each task. One
  context manager with a worker context object will be created per
  invocation to the `worker_fn` where `get_current_worker_context` can be called
  to access the worker context object.
docstr: Initialize the worker context object.
  
  Args:
    strategy: a `DistributionStrategy` object.
    cluster_spec: a ClusterSpec object. It can be empty or None in the local
      training case.
    task_type: a string indicating the role of the corresponding task, such as
      "worker" or "ps". It can be None if it is local training or in-graph
      replicated training.
    task_id: an integer indicating id of the corresponding task. It can be
      None if it is local training or in-graph replicated training.
    session_config: an optional `tf.compat.v1.ConfigProto` object.
    rpc_layer: optional string specifying the RPC protocol for communication
      with worker masters. If None or empty, hosts in the `cluster_spec` will
      be used directly.
    worker_barrier: optional, the barrier object for worker synchronization.
docstr_tok: ["Initialize","the","worker","context","object",".","Args",":","strategy",":","a","`","DistributionStrategy","`","object",".","cluster_spec",":","a","ClusterSpec","object",".","It","can","be","empty","or","None","in","the","local","training","case",".","task_type",":","a","string","indicating","the","role","of","the","corresponding","task",",","such","as","``","worker","''","or","``","ps","''",".","It","can","be","None","if","it","is","local","training","or","in-graph","replicated","training",".","task_id",":","an","integer","indicating","id","of","the","corresponding","task",".","It","can","be","None","if","it","is","local","training","or","in-graph","replicated","training",".","session_config",":","an","optional","`","tf.compat.v1.ConfigProto","`","object",".","rpc_layer",":","optional","string","specifying","the","RPC","protocol","for","communication","with","worker","masters",".","If","None","or","empty",",","hosts","in","the","`","cluster_spec","`","will","be","used","directly",".","worker_barrier",":","optional",",","the","barrier","object","for","worker","synchronization","."]
code: def __init__(
      self,
      strategy,
      cluster_spec,
      task_type,
      task_id,
      session_config=None,
      rpc_layer="grpc",
      worker_barrier=None,
  ):
      """Initialize the worker context object.
  
      Args:
        strategy: a `DistributionStrategy` object.
        cluster_spec: a ClusterSpec object. It can be empty or None in the local
          training case.
        task_type: a string indicating the role of the corresponding task, such as
          "worker" or "ps". It can be None if it is local training or in-graph
          replicated training.
        task_id: an integer indicating id of the corresponding task. It can be
          None if it is local training or in-graph replicated training.
        session_config: an optional `tf.compat.v1.ConfigProto` object.
        rpc_layer: optional string specifying the RPC protocol for communication
          with worker masters. If None or empty, hosts in the `cluster_spec` will
          be used directly.
        worker_barrier: optional, the barrier object for worker synchronization.
      """
      self._strategy = strategy
      self._cluster_spec = cluster_spec
      self._task_type = task_type
      self._task_id = task_id
      self._session_config = session_config
      self._worker_barrier = worker_barrier
      self._rpc_layer = rpc_layer
      self._master_target = self._get_master_target()
      self._num_workers = _get_num_workers(cluster_spec)
      self._is_chief_node = self._is_chief()
  
imports: import copy
  import json
  import os
  import threading
  import time
  from tensorflow.core.protobuf import config_pb2
  from tensorflow.python.client import session
  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 coordinator
  from tensorflow.python.training import monitored_session
  from tensorflow.python.training import server_lib
label_desc: Use image node_id 1 to create a new _WorkerContext object from inherited base classes: object with example: obj = _WorkerContext(strategy, cluster_spec, task_type, task_id, session_config, rpc_layer, worker_barrier)