docstr: Test to ensure force-leaf modules are not wrapped.
docstr_tok: ["Test","to","ensure","force-leaf","modules","are","not","wrapped","."]
code: def test_auto_wrap_preset_force_leaf_custom(self):
      """
      Test to ensure force-leaf modules are not wrapped.
      """
      my_auto_wrap_policy = functools.partial(
          default_auto_wrap_policy,
          min_num_params=40,
          force_leaf_modules=default_auto_wrap_policy.FORCE_LEAF_MODULES.union(
              {nn.Linear}
          ),
      )
      with enable_wrap(
          auto_wrap_policy=my_auto_wrap_policy,
          wrapper_cls=FSDP,
          process_group=self.process_group,
          flatten_parameters=False,
      ):
          sequential = nn.Sequential(
              nn.Linear(10, 10), nn.ModuleList([nn.Linear(10, 10)])
          )
          model = auto_wrap(sequential)
      # Model was wrapped in FSDP as no inner modules were wrapped.
      assert isinstance(model, FSDP)
      assert isinstance(model.module[0], nn.Linear)
      assert isinstance(model.module[1], nn.ModuleList)
  
imports: import functools
  import os
  import random
  import unittest
  import torch
  import torch.nn
  import torch.nn.functional
  from fairscale.fair_dev.testing.testing import DummyProcessGroup
  from fairscale.nn import FullyShardedDataParallel
  from fairscale.nn import auto_wrap, default_auto_wrap_policy, enable_wrap, wrap
label_desc: Use image node_id 10 for calling the TestAutoWrap obj's underlying member method code with example usage: obj.test_auto_wrap_preset_force_leaf_custom() without return types