parameters: (fn)
return_statement: return sanitized_args
docstring: Parses function definition from given completion.
  	The function might be quite complex, something like this:
  	fn(arg1 : str, arg2 : fn(arg3 : str, arg4 : str))
docstring_summary: Parses function definition from given completion.
  	The function might be quite complex, something like this:
  	fn(arg1 : str, arg2 : fn(arg3 : str, arg4 : str))
docstring_tokens: Parses function definition from given completion . The function might be quite complex something like this : fn ( arg1 : str arg2 : fn ( arg3 : str arg4 : str ))
function: def sanitize_func_def(fn):
  	"""
  	Parses function definition from given completion.
  	The function might be quite complex, something like this:
  	fn(arg1 : str, arg2 : fn(arg3 : str, arg4 : str))
  	"""
  	m = re.match(r'fn\(', fn)
  	if not m: return None
  
  	args_str = re.sub(r'->\s*[^\)]*$', '', fn).strip()
  	args_str = args_str[3:-1]
  	sanitized_args = ''
  	i = 0
  	ln = len(args_str)
  	braces_stack = 0
  
  	while i < ln:
  		ch = args_str[i]
  		if ch == '(':
  			braces_stack += 1
  			j = i + 1
  			while j < ln:
  				ch2 = args_str[j]
  				if   ch2 == '(': braces_stack += 1
  				elif ch2 == ')': braces_stack -= 1
  				if braces_stack == 0: break
  				j += 1
  
  			i = j
  		else:
  			sanitized_args += ch
  		
  		i += 1
  
  	return sanitized_args
function_tokens: def sanitize_func_def ( fn ) : m = re . match ( r'fn\(' , fn ) if not m : return None args_str = re . sub ( r'->\s*[^\)]*$' , '' , fn ) . strip ( ) args_str = args_str [ 3 : - 1 ] sanitized_args = '' i = 0 ln = len ( args_str ) braces_stack = 0 while i < ln : ch = args_str [ i ] if ch == '(' : braces_stack += 1 j = i + 1 while j < ln : ch2 = args_str [ j ] if ch2 == '(' : braces_stack += 1 elif ch2 == ')' : braces_stack -= 1 if braces_stack == 0 : break j += 1 i = j else : sanitized_args += ch i += 1 return sanitized_args