| 490 | return list(weights) |
| 491 | |
| 492 | def flatten(self): |
| 493 | transforms = [] |
| 494 | weights = [] |
| 495 | for t, w in zip(self.transforms, self.weights): |
| 496 | # if nested, probability is the current weight multiplied by the nested weights, |
| 497 | # and so on recursively |
| 498 | if isinstance(t, OneOf): |
| 499 | tr = t.flatten() |
| 500 | for t_, w_ in zip(tr.transforms, tr.weights): |
| 501 | transforms.append(t_) |
| 502 | weights.append(w_ * w) |
| 503 | else: |
| 504 | transforms.append(t) |
| 505 | weights.append(w) |
| 506 | return OneOf(transforms, weights, self.map_items, self.unpack_items) |
| 507 | |
| 508 | def __call__(self, data, start=0, end=None, threading=False, lazy: bool | None = None): |
| 509 | if start != 0: |