code: def compare_bags(testbag, goldbag, count_only=True):
      
      gold_remaining = list(goldbag)
      test_unique = []
      shared = []
      for test in testbag:
          gold_match = None
          for gold in gold_remaining:
              if isomorphic(test, gold):
                  gold_match = gold
                  break
          if gold_match is not None:
              gold_remaining.remove(gold_match)
              shared.append(test)
          else:
              test_unique.append(test)
      if count_only:
          return (len(test_unique), len(shared), len(gold_remaining))
      else:
          return (test_unique, shared, gold_remaining)
docs: Compare two bags of Xmrs objects, returning a triple of
      (unique in test, shared, unique in gold).
  
      Args:
          testbag: An iterable of Xmrs objects to test.
          goldbag: An iterable of Xmrs objects to compare against.
          count_only: If True, the returned triple will only have the
              counts of each; if False, a list of Xmrs objects will be
              returned for each (using the ones from testbag for the
              shared set)
      Returns:
          A triple of (unique in test, shared, unique in gold), where
          each of the three items is an integer count if the count_only
          parameter is True, or a list of Xmrs objects otherwise.