docstr: Verify that BarrierTaskContext.allGather() performs global sync among all barrier tasks
  within a stage and passes messages properly.
docstr_tok: ["Verify","that","BarrierTaskContext.allGather","(",")","performs","global","sync","among","all","barrier","tasks","within","a","stage","and","passes","messages","properly","."]
code: def test_all_gather(self):
      """
      Verify that BarrierTaskContext.allGather() performs global sync among all barrier tasks
      within a stage and passes messages properly.
      """
      rdd = self.sc.parallelize(range(10), 4)
  
      def f(iterator):
          yield sum(iterator)
  
      def context_barrier(x):
          tc = BarrierTaskContext.get()
          time.sleep(random.randint(1, 10))
          out = tc.allGather(str(tc.partitionId()))
          pids = [int(e) for e in out]
          return pids
  
      pids = (
          rdd.barrier()
          .mapPartitions(f)
          .map(context_barrier)
          .collect()[0]
      )
      self.assertEqual(pids, [0, 1, 2, 3])
  
imports: import os
  import random
  import stat
  import sys
  import tempfile
  import time
  import unittest
  from pyspark import SparkConf, SparkContext, TaskContext, BarrierTaskContext
  from pyspark.testing.utils import PySparkTestCase, SPARK_HOME, eventually
label_desc: Use image node_id 9 for calling the TaskContextTests obj's underlying member method code with example usage: obj.test_all_gather() and returns: pids