MCPcopy Create free account
hub / github.com/MARIO-Math-Reasoning/Super_MARIO / rebuild_tree

Function rebuild_tree

offline_inference.py:54–84  ·  view source on GitHub ↗
(
    tree_dict: Dict[str, Any], 
    max_num_children: int,
    c_puct: float,
    root_tag: str = "0",
)

Source from the content-addressed store, hash-verified

52
53
54def rebuild_tree(
55 tree_dict: Dict[str, Any],
56 max_num_children: int,
57 c_puct: float,
58 root_tag: str = "0",
59) -> Tuple[Type[InferNoder], int]:
60 root = InferNode(
61 parent=None,
62 tag=root_tag,
63 c_puct=c_puct,
64 **tree_dict[root_tag],
65 )
66 candidates = [root]
67 max_depth = 0
68 while candidates:
69 node = candidates.pop(0)
70 for idx in range(max_num_children):
71 tag = f"{node.tag}.{idx}"
72 depth = node.depth + 1
73 if tag in tree_dict:
74 child = InferNode(
75 parent=node,
76 tag=tag,
77 depth=depth,
78 c_puct=c_puct,
79 **tree_dict[tag],
80 )
81 max_depth = max(max_depth, depth)
82 node.children.append(child)
83 candidates.append(child)
84 return root, max_depth
85
86
87def is_valid_final_answer_node(node: Type[InferNode]) -> bool:

Callers 1

get_solutionFunction · 0.85

Calls 1

InferNodeClass · 0.85

Tested by

no test coverage detected