r"""Given a list of values and a ``TreeDef``, builds a pytree. This is the inverse operation of ``tree_flatten``.
(self, leaves)
| 244 | self.num_leaves = sum(ch.num_leaves for ch in children_defs) |
| 245 | |
| 246 | def unflatten(self, leaves): |
| 247 | r"""Given a list of values and a ``TreeDef``, builds a pytree. |
| 248 | This is the inverse operation of ``tree_flatten``. |
| 249 | """ |
| 250 | assert len(leaves) == self.num_leaves |
| 251 | start = 0 |
| 252 | children = [] |
| 253 | for ch in self.children_defs: |
| 254 | children.append(ch.unflatten(leaves[start : start + ch.num_leaves])) |
| 255 | start += ch.num_leaves |
| 256 | return SUPPORTED_TYPE[self.type].unflatten(children, self.aux_data) |
| 257 | |
| 258 | def __hash__(self): |
| 259 | return hash( |
no test coverage detected