@_with_ast_loc_deps<EOL>def __multi_arity_fn_to_py_ast(  <EOL>ctx: GeneratorContext,<EOL>node: Fn,<EOL>methods: Collection[FnMethod],<EOL>def_name: Optional[str] = None,<EOL>meta_node: Optional[MetaNode] = None,<EOL>) -> GeneratedPyAST:
assert node.op == NodeOp.FN<EOL>assert all([method.op == NodeOp.FN_METHOD for method in methods])<EOL>lisp_fn_name = node.local.name if node.local is not None else None<EOL>py_fn_name = __fn_name(lisp_fn_name) if def_name is None else munge(def_name)<EOL>py_fn_node = ast.AsyncFunctionDef if node.is_async else ast.FunctionDef<EOL>arity_to_name = {}<EOL>rest_arity_name: Optional[str] = None<EOL>fn_defs = []<EOL>for method in methods:<EOL><INDENT>arity_name = f"<STR_LIT>"<EOL>if method.is_variadic:<EOL><INDENT>rest_arity_name = arity_name<EOL><DEDENT>else:<EOL><INDENT>arity_to_name[method.fixed_arity] = arity_name<EOL><DEDENT>with ctx.new_symbol_table(arity_name), ctx.new_recur_point(<EOL>method.loop_id, RecurType.FN, is_variadic=node.is_variadic<EOL>):<EOL><INDENT>if lisp_fn_name is not None:<EOL><INDENT>ctx.symbol_table.new_symbol(<EOL>sym.symbol(lisp_fn_name), py_fn_name, LocalType.FN<EOL>)<EOL><DEDENT>fn_args, varg, fn_body_ast = __fn_args_to_py_ast(<EOL>ctx, method.params, method.body<EOL>)<EOL>fn_defs.append(<EOL>py_fn_node(<EOL>name=arity_name,<EOL>args=ast.arguments(<EOL>args=fn_args,<EOL>kwarg=None,<EOL>vararg=varg,<EOL>kwonlyargs=[],<EOL>defaults=[],<EOL>kw_defaults=[],<EOL>),<EOL>body=fn_body_ast,<EOL>decorator_list=[_TRAMPOLINE_FN_NAME]<EOL>if ctx.recur_point.has_recur<EOL>else [],<EOL>returns=None,<EOL>)<EOL>)<EOL><DEDENT><DEDENT>dispatch_fn_ast = __multi_arity_dispatch_fn(<EOL>ctx,<EOL>py_fn_name,<EOL>arity_to_name,<EOL>default_name=rest_arity_name,<EOL>max_fixed_arity=node.max_fixed_arity,<EOL>meta_node=meta_node,<EOL>is_async=node.is_async,<EOL>)<EOL>return GeneratedPyAST(<EOL>node=dispatch_fn_ast.node,<EOL>dependencies=list(chain(fn_defs, dispatch_fn_ast.dependencies)),<EOL>)<EOL>
Return a Python AST node for a function with multiple arities.