def METHOD_NAME(opt):
    """
    Context manager for enabling wrapping in FullyShardedDataParallel.
    """
    if not should_use_fsdp(opt):
        # make a no-op
        yield
        return
    mixed_precision = opt['fp16'] and opt['fp16_impl'] == 'safe'
    # settings as of pytorch 1.13
    # There is a warning in pytorch 1.13 for FSDP that is unavoidable;
    # at the risk of suppressing valid warnings, just going to suppress that one.
    import warnings
    warnings.filterwarnings("ignore")
    # sharding strategy determines zero2 or zero3
    sharding_strategy = (
        ShardingStrategy.FULL_SHARD
        if opt['ddp_backend'] == 'zero3'
        else ShardingStrategy.SHARD_GRAD_OP
    )
    # mp determines how to mix precision
    if mixed_precision:
        mp_strategy = MixedPrecision(
            reduce_dtype=torch.float16,
            param_dtype=torch.float16,
            buffer_dtype=torch.float16,
        )
    else:
        mp_strategy = None
    # autowrap policy.
    auto_wrap_policy = None
    ignored_modules = None
    if 'hugging_face' not in opt['model']:
        from parlai.agents.transformer.modules.encoder import (
            TransformerEncoderLayer,
        )
        from parlai.agents.transformer.modules.decoder import (
            TransformerDecoderLayer,
        )
        auto_wrap_policy = functools.partial(
            transformer_auto_wrap_policy,
            transformer_layer_cls={
                TransformerEncoderLayer,
                TransformerDecoderLayer,
            },
        )
    # backward prefetch; determines when to fetch the parameters during backward pass
    # set to BACKWARD_PRE to increase throughput, at the cost of memory
    backward_prefetch = BackwardPrefetch.BACKWARD_POST
    # CPU offloading; this can offload parameters to the CPU
    cpu_offload = None
    fsdp_args = dict(
        process_group=get_dist_group(),
        sharding_strategy=sharding_strategy,
        cpu_offload=cpu_offload,
        auto_wrap_policy=auto_wrap_policy,
        backward_prefetch=backward_prefetch,
        mixed_precision=mp_strategy,
        ignored_modules=ignored_modules,
        param_init_fn=None,
        device_id=opt['gpu'],
        sync_module_states=False,  # need this for syncing the first call; specify False because we do it manually after cuda
        forward_prefetch=False,  # specify true for CPU-heavy workload
        limit_all_gathers=False,  # specifying the default here
    )
    with enable_wrap(wrapper_cls=FSDP, **fsdp_args):
        yield