code: def _get_fqn_to_fsdp_param_info(
      model: nn.Module,
  ) -> Dict[str, FSDPParamInfo]:
      """
      Construct the mapping from a param's fqn to its corresponding ``FSDPParamInfo``
      if the param is managed by FSDP. Shared parameters, or original parameters that
      are shared across multiple nn.Modules, are required to belong to one and only
      one FSDP instance and thus correspond to one ``FlatParameter``. Within the one
      ``FlatParameter``, ``FlatParameter._fqns`` only stores the first FQN of a shared
      parameter. Thus, the keys in the mapping are guaranteed to map to unique parameters.
      """
  
      def module_fn(module, prefix, tree_level, fqn_to_param_info):
          fsdp_state = _get_module_fsdp_state_if_fully_sharded_module(
              module
          )
          if fsdp_state is None:
              return
          _lazy_init(fsdp_state, module)
          handle = _module_handle(fsdp_state, module)
          if not handle:
              return
          flat_param = handle.flat_param
          fsdp_param_info = FSDPParamInfo(fsdp_state, handle, {}, [])
          # NOTE: `idx` indexes into the data structures *without* padding
          # elements
          for idx, local_fqn in enumerate(flat_param._fqns):
              fqn = clean_tensor_name(prefix + local_fqn)
              if fqn in fqn_to_param_info:
                  assert (
                      fqn_to_param_info[fqn].handle.flat_param
                      is flat_param
                  ), fqn
              fqn_to_param_info[fqn] = fsdp_param_info
              fsdp_param_info.param_indices[fqn] = idx
              if flat_param._params is not None:
                  fsdp_param_info.param_requires_grad.append(
                      flat_param._params[idx].requires_grad
                  )
  
      def return_fn(fqn_to_param_info):
          return fqn_to_param_info
  
      fqn_to_param_info: Dict[str, FSDPParamInfo] = {}
      # FlatParameter._fqns stores the local fqn, starting from the root of the
      # FSDP. Using _apply_to_modules() with model (may not be the FSDP root
      # module) allows us to construct the global fqn.
      return _apply_to_modules(
          model,
          module_fn,
          return_fn,
          [fqn for fqn, _ in _named_parameters_with_duplicates(model)],
          fqn_to_param_info,
      )
  
imports: import copy
  import functools
  import logging
  import warnings
  from contextlib import ExitStack
  from dataclasses import dataclass, field
  from typing import Any, cast, Dict, Iterable, Iterator, List, NamedTuple, no_type_check, Optional, Sequence, Set, Tuple, Union
  import torch
  import torch.distributed
  import torch.distributed.fsdp._traversal_utils
  import torch.nn
  from torch.distributed._shard.sharded_tensor import ShardedTensor
  from torch.distributed._state_dict_utils import _gather_state_dict
  from torch.distributed._tensor import DTensor, Replicate
  from torch.distributed.distributed_c10d import _get_pg_default_device
  from torch.distributed.fsdp._common_utils import _apply_to_modules, _FSDPState, _get_module_fsdp_state_if_fully_sharded_module, _get_param_to_fqns, _module_handle, _named_parameters_with_duplicates, clean_tensor_name
  from torch.distributed.fsdp._debug_utils import SimpleProfiler
  from torch.distributed.fsdp._flat_param import FlatParameter, FlatParamHandle
  from torch.distributed.fsdp._fsdp_extensions import _ext_chunk_dtensor, _ext_chunk_tensor
  from torch.distributed.fsdp._runtime_utils import _lazy_init, _reset_flat_param_grad_info_if_needed
  from torch.distributed.fsdp.api import ShardingStrategy, StateDictSettings, StateDictType
  from torch.utils._pytree import tree_map_only
label_desc: Use image node_id 32 for calling a global function with example usage: _get_fqn_to_fsdp_param_info(model) and returns: _apply_to_modules, fqn_to_param_info