code: def __init__(self, comm, init=0):
      #
      size = comm.Get_size()
      rank = comm.Get_rank()
      mask = 1
      while mask < size:
          mask <<= 1
      mask >>= 1
      idx = 0
      get_idx = []
      acc_idx = []
      while mask >= 1:
          left = idx + 1
          right = idx + (mask << 1)
          if rank < mask:
              acc_idx.append(left)
              get_idx.append(right)
              idx = left
          else:
              acc_idx.append(right)
              get_idx.append(left)
              idx = right
          rank = rank % mask
          mask >>= 1
      #
      typecode = "i"
      datatype = MPI.INT
      itemsize = datatype.Get_size()
      #
      root = 0
      rank = comm.Get_rank()
      if rank == root:
          nlevels = len(get_idx) + 1
          nentries = (1 << nlevels) - 1
          self.mem = MPI.Alloc_mem(nentries * itemsize, MPI.INFO_NULL)
          self.mem[:] = _struct.pack(typecode, init) * nentries
      else:
          self.mem = None
      #
      self.win = MPI.Win.Create(self.mem, itemsize, MPI.INFO_NULL, comm)
      self.acc_type = datatype.Create_indexed_block(1, acc_idx).Commit()
      self.get_type = datatype.Create_indexed_block(1, get_idx).Commit()
      self.acc_buf = _array_new(len(acc_idx), typecode)
      self.get_buf = _array_new(len(get_idx), typecode)
      self.myval = 0
  
file_path: mpi4py/demo/nxtval/nxtval-scalable.py
imports: from mpi4py import MPI
  import struct
label_desc: Use image node_id 1 to create a new Counter object  with example: obj = Counter(comm, init)