code: def get_item_cnt(results, attrname="study_items"):
          
          items = set()
          go_cnt = 0
          for rec in results:
              if hasattr(rec, attrname):
                  items_cur = getattr(rec, attrname)
                  # Only count GO term if there are items in the set.
                  if len(items_cur) != 0:
                      items |= items_cur
                      go_cnt += 1
          return items, go_cnt
docs: Get all study or population items (e.g., geneids).