code: def test_update_dataloader_typerror_custom_exception():
      class BadStandaloneGoodHookImpl(DataLoader):
          def __init__(self, foo, *args, **kwargs):
              self.foo = foo
              # positional conflict with `dataset`
              super().__init__(foo, *args, **kwargs)
  
      dataloader = BadStandaloneGoodHookImpl([1, 2, 3])
      with pytest.raises(
          MisconfigurationException,
          match="implementation has an error.*`dataset`",
      ):
          _update_dataloader(dataloader, dataloader.sampler)
  
      with _replace_dunder_methods(DataLoader, "dataset"):
          dataloader = BadStandaloneGoodHookImpl([1, 2, 3])
      new_dataloader = _update_dataloader(
          dataloader, dataloader.sampler
      )
      assert isinstance(new_dataloader, BadStandaloneGoodHookImpl)
  
      class BadImpl(DataLoader):
          def __init__(self, randomize, *args, **kwargs):
              self.randomize = randomize
              # keyword conflict with `shuffle`
              super().__init__(*args, shuffle=randomize, **kwargs)
  
      dataloader = BadImpl(False, [])
      with pytest.raises(
          MisconfigurationException,
          match="implementation has an error.*`shuffle`",
      ):
          _update_dataloader(dataloader, dataloader.sampler)
  
      class GoodImpl(DataLoader):
          def __init__(self, randomize, *args, **kwargs):
              # fixed implementation, kwargs are filtered
              self.randomize = randomize or kwargs.pop("shuffle", False)
              super().__init__(*args, shuffle=randomize, **kwargs)
  
      dataloader = GoodImpl(False, [])
      new_dataloader = _update_dataloader(
          dataloader, dataloader.sampler
      )
      assert isinstance(new_dataloader, GoodImpl)
  
imports: from dataclasses import dataclass
  from unittest.mock import Mock
  import numpy
  import pytest
  import torch
  from lightning.fabric.utilities.data import _replace_dunder_methods
  from lightning.pytorch import Trainer
  from lightning.pytorch.demos.boring_classes import RandomDataset, RandomIterableDataset
  from lightning.pytorch.overrides.distributed import _IndexBatchSamplerWrapper
  from lightning.pytorch.trainer.states import RunningStage
  from lightning.pytorch.utilities.data import _get_dataloader_init_args_and_kwargs, _update_dataloader, extract_batch_size, has_len_all_ranks, warning_cache
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning_utilities.test.warning import no_warning_call
  from torch import Tensor
  from torch.utils.data import BatchSampler, DataLoader, RandomSampler
label_desc: Use image node_id 3 for calling a global function with example usage: test_update_dataloader_typerror_custom_exception() without return types