parameters: (self, refs)
return_statement: return sorted(iter(collapsed_refs.items()), key=lambda x: -x[1])
docstring: Takes and returns a list of ref, count tuples. 
  		Merge together results for refs for which one is a specification of the other.
  		E.g., if "Shabbat 21a", and "Shabbat 21:5" both appear, add their counts together and keep the mores specific ref.
docstring_summary: Takes and returns a list of ref, count tuples. 
  		Merge together results for refs for which one is a specification of the other.
  		E.g., if "Shabbat 21a", and "Shabbat 21:5" both appear, add their counts together and keep the mores specific ref.
docstring_tokens: Takes and returns a list of ref count tuples . Merge together results for refs for which one is a specification of the other . E . g . if Shabbat 21a and Shabbat 21 : 5 both appear add their counts together and keep the mores specific ref .
function: def collapse_ref_counts(self, refs):
  		"""
  		Takes and returns a list of ref, count tuples. 
  		Merge together results for refs for which one is a specification of the other.
  		E.g., if "Shabbat 21a", and "Shabbat 21:5" both appear, add their counts together and keep the mores specific ref.
  		"""
  		collapsed_refs = {}
  		for ref1 in refs:
  			matched = False
  			for ref2 in refs:
  				if ref1 == ref2:
  					continue
  				oRef1, oRef2 = Ref(ref1[0]), Ref(ref2[0])
  				if oRef2.contains(oRef1):
  					collapsed_refs[ref1[0]] = ref1[1] + ref2[1]
  				if oRef2.contains(oRef1) or oRef1.contains(oRef2):
  					matched = True
  			if not matched:
  				collapsed_refs[ref1[0]] = ref1[1]
  		return sorted(iter(collapsed_refs.items()), key=lambda x: -x[1])
function_tokens: def collapse_ref_counts ( self , refs ) : collapsed_refs = { } for ref1 in refs : matched = False for ref2 in refs : if ref1 == ref2 : continue oRef1 , oRef2 = Ref ( ref1 [ 0 ] ) , Ref ( ref2 [ 0 ] ) if oRef2 . contains ( oRef1 ) : collapsed_refs [ ref1 [ 0 ] ] = ref1 [ 1 ] + ref2 [ 1 ] if oRef2 . contains ( oRef1 ) or oRef1 . contains ( oRef2 ) : matched = True if not matched : collapsed_refs [ ref1 [ 0 ] ] = ref1 [ 1 ] return sorted ( iter ( collapsed_refs . items ( ) ) , key = lambda x : - x [ 1 ] )