r""" Performs a depth-first search on the given PyTorch model and returns a list of all its child modules. Args: model (torch.nn.Module): The PyTorch model to perform the depth-first search on. Returns: list: A list of all child modules of the given model.
(model: torch.nn.Module)
| 65 | |
| 66 | |
| 67 | def torch_dfs(model: torch.nn.Module): |
| 68 | r""" |
| 69 | Performs a depth-first search on the given PyTorch model and returns a list of all its child modules. |
| 70 | |
| 71 | Args: |
| 72 | model (torch.nn.Module): The PyTorch model to perform the depth-first search on. |
| 73 | |
| 74 | Returns: |
| 75 | list: A list of all child modules of the given model. |
| 76 | """ |
| 77 | result = [model] |
| 78 | for child in model.children(): |
| 79 | result += torch_dfs(child) |
| 80 | return result |
| 81 | |
| 82 | |
| 83 | class StableDiffusionReferencePipeline( |