code: def fsdp_wrap(module, min_num_params: Optional[int] = None, **kwargs):
      """
      Helper to wrap layers/modules in FSDP. This falls back to a no-op if
      fairscale is not available.
  
      Args:
          module (nn.Module): module to (maybe) wrap
          min_num_params (int, Optional): minimum number of layer params to wrap
      """
      try:
          from fairscale.nn import wrap
  
          if min_num_params is not None:
              num_params = sum(p.numel() for p in module.parameters())
              if num_params >= min_num_params:
                  return wrap(module, **kwargs)
              else:
                  return module
          else:
              return wrap(module, **kwargs)
      except ImportError:
          return module
  
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 2 for calling a global function with example usage: fsdp_wrap(module, min_num_params) and returns: wrap, module, wrap, module