code: def test_has_meta_device_parameters():
      """Test that the `_has_meta_device_parameters` function can find meta-device parameters in models and
      optimizers."""
      # nn.Module
      module = nn.Linear(2, 2)
      meta_module = nn.Linear(2, 2, device="meta")
      assert not _has_meta_device_parameters(module)
      assert _has_meta_device_parameters(meta_module)
      assert _has_meta_device_parameters(
          nn.Sequential(module, meta_module, nn.ReLU())
      )
      # optim.Optimizer
      optimizer = torch.optim.SGD(module.parameters(), lr=0.1)
      meta_optimizer = torch.optim.SGD(meta_module.parameters(), lr=0.1)
      assert not _has_meta_device_parameters(optimizer)
      assert _has_meta_device_parameters(meta_optimizer)
      # unsupported objects
      with pytest.raises(
          TypeError,
          match="Expected `torch.nn.Module` or `torch.optim.Optimizer`",
      ):
          _has_meta_device_parameters(None)
  
imports: from datetime import timedelta
  from re import escape
  from unittest import mock
  from unittest.mock import ANY, MagicMock, Mock
  import lightning.fabric
  import pytest
  import torch
  import torch.nn
  from lightning.fabric.plugins import HalfPrecision
  from lightning.fabric.plugins.environments import LightningEnvironment
  from lightning.fabric.strategies import FSDPStrategy
  from lightning.fabric.strategies.fsdp import _FSDPBackwardSyncControl, _get_full_state_dict_context, _has_meta_device_parameters, _is_sharded_checkpoint
  from lightning.fabric.utilities.imports import _TORCH_GREATER_EQUAL_2_1
  from torch.distributed.fsdp.fully_sharded_data_parallel import CPUOffload, FullyShardedDataParallel, MixedPrecision
  from torch.optim import Adam
  from tests_fabric.helpers.runif import RunIf
label_desc: Use image node_id 23 for calling a global function with example usage: test_has_meta_device_parameters() without return types