<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def match_patterns(codedata) : 	""" Match patterns by shaman.PatternMatcher 		Get average ratio of pattern and language 	"""


	ret = {}

	for index1, pattern in enumerate(shaman.PatternMatcher.PATTERNS) :
		print('Matching pattern %d "%s"' % (index1+1, pattern))

		matcher = shaman.PatternMatcher(pattern)
		tmp = {}

		for index2, (language, code) in enumerate(codedata) :
			if language not in shaman.SUPPORTING_LANGUAGES :
				continue

			if len(code) <= 20 or len(code) > 100000 :
				continue

			if language not in tmp :
				tmp[language] = []

			ratio = matcher.getratio(code)
			tmp[language].append(ratio)

			print('Matching patterns %d/%d    ' % (index2, len(codedata)), end='\r')


		ret[pattern] = {}
		for language, data in tmp.items() :
			ret[pattern][language] = sum(tmp[language]) / max(len(tmp[language]), 1)

	print('Matching patterns completed          ')
	return ret