Recursively flatten input and yield all instances of `MetaObj`. This means that for both `torch.add(a, b)`, `torch.stack([a, b])` (and their numpy equivalents), we return `[a, b]` if both `a` and `b` are of type `MetaObj`. Args: args: Iterables o
(*args: Iterable)
| 87 | |
| 88 | @staticmethod |
| 89 | def flatten_meta_objs(*args: Iterable): |
| 90 | """ |
| 91 | Recursively flatten input and yield all instances of `MetaObj`. |
| 92 | This means that for both `torch.add(a, b)`, `torch.stack([a, b])` (and |
| 93 | their numpy equivalents), we return `[a, b]` if both `a` and `b` are of type |
| 94 | `MetaObj`. |
| 95 | |
| 96 | Args: |
| 97 | args: Iterables of inputs to be flattened. |
| 98 | Returns: |
| 99 | list of nested `MetaObj` from input. |
| 100 | """ |
| 101 | for a in itertools.chain(*args): |
| 102 | if isinstance(a, (list, tuple)): |
| 103 | yield from MetaObj.flatten_meta_objs(a) |
| 104 | elif isinstance(a, MetaObj): |
| 105 | yield a |
| 106 | |
| 107 | @staticmethod |
| 108 | def copy_items(data): |