code: def _create_task_process(
      task_type,
      task_index,
      estimator_type,
      placement_strategy,
      tf_config,
      model_dir,
  ):
      """Creates a process for a single estimator task.
  
      Args:
        task_type: 'chief', 'worker' or 'ps'.
        task_index: The index of the task within the cluster.
        estimator_type: The estimator type to train. 'estimator' or 'autoensemble'.
        placement_strategy: The distributed placement strategy.
        tf_config: Dictionary representation of the TF_CONFIG environment variable.
          This method creates a copy as to not mutate the input dict.
        model_dir: The Estimator's model directory.
  
      Returns:
        A _ProcessInfo namedtuple of the running process. The stderr field of this
          tuple must be closed by the caller once the process ends.
      """
  
      process_name = "%s_%s" % (task_type, task_index)
      args = [
          "python",
          "adanet/core/estimator_distributed_test_runner.py",
      ]
      args.append("--estimator_type={}".format(estimator_type))
      args.append("--placement_strategy={}".format(placement_strategy))
      # Log everything to stderr.
      args.append("--stderrthreshold=info")
      args.append("--model_dir={}".format(model_dir))
      logging.info(
          "Spawning %s process: %s", process_name, " ".join(args)
      )
      stderr_filename = os.path.join(
          model_dir, "%s_stderr.txt" % process_name
      )
      logging.info("Logging to %s", model_dir)
      stderr_file = open(stderr_filename, "w+")
      tf_config = copy.deepcopy(tf_config)
      tf_config["task"]["type"] = task_type
      tf_config["task"]["index"] = task_index
      json_tf_config = json.dumps(tf_config)
      env = os.environ.copy()
      # Allow stderr to be viewed before the process ends.
      env["PYTHONUNBUFFERED"] = "1"
      env["TF_CPP_MIN_LOG_LEVEL"] = "0"
      env["TF_CONFIG"] = json_tf_config
      # Change gRPC polling strategy to prevent blocking forever.
      # See https://github.com/tensorflow/tensorflow/issues/17852.
      env["GRPC_POLL_STRATEGY"] = "poll"
      popen = subprocess.Popen(args, stderr=stderr_file, env=env)
      return _ProcessInfo(process_name, popen, stderr_file)
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import collections
  import copy
  import itertools
  import json
  import os
  import shutil
  import socket
  import subprocess
  import sys
  import time
  from absl import flags
  from absl import logging
  from absl.testing import parameterized
  from adanet import tf_compat
  from adanet.core.timer import _CountDownTimer
  import tensorflow.compat.v2
label_desc: Use image node_id 1 for calling a global function with example usage: _create_task_process(task_type, task_index, estimator_type, placement_strategy, tf_config, model_dir) and returns: _ProcessInfo