code: def test_pruning_lth_callable(tmpdir, resample_parameters: bool):
      model = TestModel()
  
      class ModelPruningTestCallback(ModelPruning):
          lth_calls = 0
  
          def apply_lottery_ticket_hypothesis(self):
              super().apply_lottery_ticket_hypothesis()
              self.lth_calls += 1
  
              for d in self._original_layers.values():
                  copy, names = d["data"], d["names"]
                  for i, name in names:
                      curr, curr_name = self._parameters_to_prune[i]
                      assert name == curr_name
                      actual, expected = (
                          getattr(curr, name).data,
                          getattr(copy, name).data,
                      )
                      allclose = torch.allclose(actual, expected)
                      assert (
                          not allclose
                          if self._resample_parameters
                          else allclose
                      )
  
      pruning = ModelPruningTestCallback(
          "l1_unstructured",
          use_lottery_ticket_hypothesis=lambda e: bool(e % 2),
          resample_parameters=resample_parameters,
      )
      trainer = Trainer(
          default_root_dir=tmpdir,
          enable_progress_bar=False,
          enable_model_summary=False,
          enable_checkpointing=False,
          logger=False,
          limit_train_batches=10,
          limit_val_batches=2,
          max_epochs=5,
          callbacks=pruning,
      )
      trainer.fit(model)
  
      assert pruning.lth_calls == trainer.max_epochs // 2
  
imports: import re
  from collections import OrderedDict
  from logging import INFO
  from typing import Union
  import pytest
  import torch
  import torch.nn.utils.prune
  from lightning.pytorch import Trainer, seed_everything
  from lightning.pytorch.callbacks import ModelCheckpoint, ModelPruning
  from lightning.pytorch.demos.boring_classes import BoringModel
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from torch import nn
  from torch.nn import Sequential
  from tests_pytorch.helpers.runif import RunIf
label_desc: Use image node_id 7 for calling a global function with example usage: test_pruning_lth_callable(tmpdir, resample_parameters) without return types