class_docstr: A small wrapper around fairscale's FullyShardedDataParallel (FSDP) with some
  fairseq-specific checkpoint saving/loading logic.
  
  Args:
      use_sharded_state (bool): if True, then ``state_dict`` will return
          ``FSDP.local_state_dict`` and ``load_state_dict`` will call
          ``FSDP.load_local_state_dict``. Otherwise, ``state_dict`` will
          return the full model weights on data parallel rank 0 (empty on
          other ranks) and ``load_state_dict`` will broadcast model weights
          from rank 0 to other ranks.
class_docstr_tok: ["A","small","wrapper","around","fairscale","'s","FullyShardedDataParallel","(","FSDP",")","with","some","fairseq-specific","checkpoint","saving\/loading","logic",".","Args",":","use_sharded_state","(","bool",")",":","if","True",",","then","``","state_dict","``","will","return","``","FSDP.local_state_dict","``","and","``","load_state_dict","``","will","call","``","FSDP.load_local_state_dict","``",".","Otherwise",",","``","state_dict","``","will","return","the","full","model","weights","on","data","parallel","rank","0","(","empty","on","other","ranks",")","and","``","load_state_dict","``","will","broadcast","model","weights","from","rank","0","to","other","ranks","."]
code: def state_dict(self, destination=None, prefix="", keep_vars=False):
      if self.use_sharded_state:
          return super().local_state_dict(
              destination=destination,
              prefix=prefix,
              keep_vars=keep_vars,
          )
      else:
          if self.rank == 0:
              return super().state_dict(
                  destination=destination,
                  prefix=prefix,
                  keep_vars=keep_vars,
              )
          else:
              # We must call state_dict() due to use of communication
              # primitives. But we don't use the result.
              super().state_dict()
              return destination or {}
  
file_path: fairseq/fairseq/distributed/fully_sharded_data_parallel.py
imports: import contextlib
  from typing import Optional
  import torch
  from fairseq.dataclass.configs import DistributedTrainingConfig
  from fairseq.distributed import utils
label_desc: Use image node_id 3 for calling the FullyShardedDataParallel obj's underlying member method code with example usage: obj.state_dict(destination, prefix, keep_vars) and returns: super, super, unknown