code: def test_is_wrapped(compile):
      """Test that the `is_wrapped` utility recognizes when an object was wrapped by Fabric."""
      assert not is_wrapped(None)
  
      # _FabricModule
      module = torch.nn.Linear(2, 2)
      assert not is_wrapped(module)
      wrapped = _FabricModule(module, Mock())
      assert is_wrapped(wrapped)
  
      # _FabricModule inside an OptimizedModule
      if compile:
          from torch._dynamo import OptimizedModule
  
          module = torch.nn.Linear(2, 2)
          wrapped = torch.compile(_FabricModule(module, Mock()))
          assert isinstance(wrapped, OptimizedModule)
          assert is_wrapped(wrapped)
  
      # _FabricOptimizer
      optimizer = torch.optim.Adam(module.parameters())
      assert not is_wrapped(optimizer)
      wrapped = _FabricOptimizer(optimizer, Mock())
      assert is_wrapped(wrapped)
  
      # _FabricDataLoader
      dataloader = DataLoader([1, 2, 3])
      assert not is_wrapped(dataloader)
      wrapped = _FabricDataLoader(dataloader)
      assert is_wrapped(wrapped)
  
imports: from unittest import mock
  from unittest.mock import Mock, call
  import pytest
  import torch
  from lightning.fabric.fabric import Fabric
  from lightning.fabric.plugins import Precision
  from lightning.fabric.utilities.device_dtype_mixin import _DeviceDtypeModuleMixin
  from lightning.fabric.utilities.imports import _TORCH_GREATER_EQUAL_2_1
  from lightning.fabric.wrappers import _FabricDataLoader, _FabricModule, _FabricOptimizer, _unwrap_objects, is_wrapped
  from torch.utils.data import BatchSampler, DistributedSampler
  from torch.utils.data.dataloader import DataLoader
  from tests_fabric.helpers.runif import RunIf
label_desc: Use image node_id 16 for calling a global function with example usage: test_is_wrapped(compile) without return types