code: def mergeDescriptor(self, p1, p2, name, dim):
      def copyPool(origin, to):
          for desc in origin.descriptorNames():
              if origin.isSingleValue(desc):
                  to.set(desc, origin[desc])
              else:
                  for val in origin[desc]:
                      to.add(desc, val)
  
      def interleave(x, y):
          result = []
          for val in zip(x, y):
              for elem in val:
                  result.append(elem)
          return result
  
      p = Pool()
      copyPool(p1, p)
  
      if name in numpy.intersect1d(
          p1.descriptorNames(), p2.descriptorNames()
      ):
          self.assertRaises(EssentiaException, p1.merge, name, p2[name])
      p1.merge(p2, "replace")
      if (
          not dim or dim == 0 and name in p1.descriptorNames()
      ):  # int, float, string
          self.assertEqual(p1[name], p2[name])
      elif dim == 1:  # vector_*
          self.assertEqualVector(p1[name], p2[name])
      elif dim == 2:  # vector_vector_*
          self.assertEqualMatrix(p1[name], p2[name])
      elif dim == 3:  # array2d
          for i in range(len(p1[name])):
              self.assertEqualMatrix(p1[name][i], p2[name][i])
      p1.clear()
      copyPool(p, p1)
      p1.merge(p2, "append")
      if (
          not dim or dim == 0 and name in p1.descriptorNames()
      ):  # int, float, string
          self.assertRaises(EssentiaException, p1.merge, name, p2[name])
      elif dim == 1:  # vector_*
          self.assertEqualVector(
              p1[name], numpy.concatenate((p[name], p2[name]))
          )
      elif dim == 2:  # vector_vector_*
          self.assertEqualMatrix(
              p1[name], numpy.concatenate((p[name], p2[name]))
          )
      elif dim == 3:  # array2d
          for i in range(len(p1[name])):
              if i < len(p[name]):
                  expected = p[name][i]
              else:
                  expected = p2[name][i - len(p[name])]
              self.assertEqualMatrix(p1[name][i], expected)
  
      p1.clear()
      copyPool(p, p1)
      p1.merge(p2, "interleave")
      if (
          not dim or dim == 0 and name in p1.descriptorNames()
      ):  # int, float, string
          self.assertRaises(EssentiaException, p1.merge, name, p2[name])
      elif dim == 1:  # vector_*
          self.assertEqualVector(
              p1[name], interleave(p[name], p2[name])
          )
      elif dim == 2:  # vector_vector_*
          self.assertEqualMatrix(
              p1[name], interleave(p[name], p2[name])
          )
      elif dim == 3:  # array2d
          expected = interleave(p[name], p2[name])
          for i in range(len(p1[name])):
              self.assertEqualMatrix(p1[name][i], expected[i])
  
imports: from essentia_test import *
label_desc: Use image node_id 35 for calling the TestPool obj's underlying member method code with example usage: obj.mergeDescriptor(p1, p2, name, dim) and returns: result