code: def _get_modules_to_materialize(
      root_module: nn.Module, ignored_modules: Set[nn.Module]
  ) -> List[nn.Module]:
      # Run BFS to collect the modules to materialize via `reset_parameters()`,
      # stopping at any module with FSDP already applied or at ignored modules.
      modules_to_materialize: List[nn.Module] = []
      queue = collections.deque([root_module])
      visited_modules: Set[nn.Module] = {root_module}
      while queue:
          module = queue.popleft()
          modules_to_materialize.append(module)
          for child_module in module.children():
              if (
                  child_module not in visited_modules
                  and _get_module_fsdp_state(child_module) is None
                  and child_module not in ignored_modules
              ):
                  visited_modules.add(child_module)
                  queue.append(child_module)
      return modules_to_materialize
  
imports: import collections
  import itertools
  import os
  import warnings
  from typing import Any, Callable, Deque, Dict, Generator, Iterable, Iterator, List, no_type_check, Optional, Set, Tuple, Union
  import torch
  import torch.distributed
  import torch.distributed.fsdp._exec_order_utils
  import torch.distributed.fsdp._traversal_utils
  import torch.distributed.fsdp.fully_sharded_data_parallel
  import torch.nn
  from torch.distributed.algorithms._comm_hooks import default_hooks
  from torch.distributed.device_mesh import _mesh_resources, DeviceMesh
  from torch.distributed.distributed_c10d import _get_default_group
  from torch.distributed.fsdp._common_utils import _FSDPDeviceHandle, _FSDPState, _get_module_fsdp_state, _is_fsdp_flattened, _named_parameters_with_duplicates, clean_tensor_name, TrainingState
  from torch.distributed.fsdp._flat_param import _FSDP_USE_FULL_PREC_IN_EVAL, FlatParameter, FlatParamHandle, HandleShardingStrategy
  from torch.distributed.fsdp._limiter_utils import _FreeEventQueue
  from torch.distributed.fsdp.api import BackwardPrefetch, CPUOffload, FullOptimStateDictConfig, FullStateDictConfig, MixedPrecision, ShardingStrategy, StateDictConfig, StateDictType
  from torch.distributed.fsdp.wrap import _Policy
  from torch.distributed.tensor.parallel.fsdp import DTensorExtensions
  from torch.distributed.utils import _sync_params_and_buffers
  from torch.utils._python_dispatch import is_traceable_wrapper_subclass
  from torch.utils.hooks import RemovableHandle
label_desc: Use image node_id 28 for calling a global function with example usage: _get_modules_to_materialize(root_module, ignored_modules) and returns: modules_to_materialize