class_docstr: Entry point to model parallelism.
  
  Args:
      module (nn.Module): module to wrap.
      env (Optional[ShardingEnv]): sharding environment that has the process group.
      device (Optional[torch.device]): compute device, defaults to cpu.
      plan (Optional[ShardingPlan]): plan to use when sharding, defaults to
          `EmbeddingShardingPlanner.collective_plan()`.
      sharders (Optional[List[ModuleSharder[nn.Module]]]): `ModuleSharders` available
          to shard with, defaults to `EmbeddingBagCollectionSharder()`.
      init_data_parallel (bool): data-parallel modules can be lazy, i.e. they delay
          parameter initialization until the first forward pass. Pass `True` to delay
          initialization of data parallel modules. Do first forward pass and then call
          DistributedModelParallel.init_data_parallel().
      init_parameters (bool): initialize parameters for modules still on meta device.
      data_parallel_wrapper (Optional[DataParallelWrapper]): custom wrapper for data
          parallel modules.
  
  Example::
  
      @torch.no_grad()
      def init_weights(m):
          if isinstance(m, nn.Linear):
              m.weight.fill_(1.0)
          elif isinstance(m, EmbeddingBagCollection):
              for param in m.parameters():
                  init.kaiming_normal_(param)
  
      m = MyModel(device='meta')
      m = DistributedModelParallel(m)
      m.apply(init_weights)
class_docstr_tok: ["Entry","point","to","model","parallelism",".","Args",":","module","(","nn.Module",")",":","module","to","wrap",".","env","(","Optional","[","ShardingEnv","]",")",":","sharding","environment","that","has","the","process","group",".","device","(","Optional","[","torch.device","]",")",":","compute","device",",","defaults","to","cpu",".","plan","(","Optional","[","ShardingPlan","]",")",":","plan","to","use","when","sharding",",","defaults","to","`","EmbeddingShardingPlanner.collective_plan","(",")","`",".","sharders","(","Optional","[","List","[","ModuleSharder","[","nn.Module","]","]","]",")",":","`","ModuleSharders","`","available","to","shard","with",",","defaults","to","`","EmbeddingBagCollectionSharder","(",")","`",".","init_data_parallel","(","bool",")",":","data-parallel","modules","can","be","lazy",",","i.e",".","they","delay","parameter","initialization","until","the","first","forward","pass",".","Pass","`","True","`","to","delay","initialization","of","data","parallel","modules",".","Do","first","forward","pass","and","then","call","DistributedModelParallel.init_data_parallel","(",")",".","init_parameters","(","bool",")",":","initialize","parameters","for","modules","still","on","meta","device",".","data_parallel_wrapper","(","Optional","[","DataParallelWrapper","]",")",":","custom","wrapper","for","data","parallel","modules",".","Example",":",":","@","torch.no_grad","(",")","def","init_weights","(","m",")",":","if","isinstance","(","m",",","nn.Linear",")",":","m.weight.fill_","(","1.0",")","elif","isinstance","(","m",",","EmbeddingBagCollection",")",":","for","param","in","m.parameters","(",")",":","init.kaiming_normal_","(","param",")","m","=","MyModel","(","device='meta","'",")","m","=","DistributedModelParallel","(","m",")","m.apply","(","init_weights",")"]
code: def named_parameters(
      self,
      prefix: str = "",
      recurse: bool = True,
      remove_duplicate: bool = True,
  ) -> Iterator[Tuple[str, torch.nn.Parameter]]:
      gen = self._named_parameters(
          self.module,
          prefix,
          recurse,
      )
      memo = set()
      for key, param in gen:
          if param in memo:
              continue
          if remove_duplicate:
              memo.add(param)
          yield key, param
  
imports: import abc
  import copy
  from collections import OrderedDict
  from typing import Any, cast, Dict, Iterator, List, Optional, Set, Tuple, Type
  import torch
  import torch.distributed
  from torch import nn
  from torch.distributed.algorithms.ddp_comm_hooks import default_hooks
  from torch.distributed.fsdp import FullyShardedDataParallel
  from torch.nn.modules.module import _IncompatibleKeys
  from torch.nn.parallel import DistributedDataParallel
  from torchrec.distributed.comm import get_local_size
  from torchrec.distributed.planner import EmbeddingShardingPlanner, Topology
  from torchrec.distributed.sharding_plan import get_default_sharders
  from torchrec.distributed.types import ModuleSharder, ShardedModule, ShardingEnv, ShardingPlan
  from torchrec.distributed.utils import add_prefix_to_state_dict, append_prefix, copy_to_device, filter_state_dict, sharded_model_copy
  from torchrec.optim.fused import FusedOptimizerModule
  from torchrec.optim.keyed import CombinedOptimizer, KeyedOptimizer
label_desc: Use image node_id 18 for calling the DistributedModelParallel obj's underlying member method code with example usage: obj.named_parameters(prefix, recurse, remove_duplicate) without return types