code: def test_overfit_batches_raises_warning_in_case_of_sequential_sampler(
      tmpdir,
  ):
      class NonSequentialSampler(Sampler):
          def __init__(self, data_source):
              self.data_source = data_source
  
          def __iter__(self):
              return iter(range(len(self.data_source)))
  
          def __len__(self):
              return len(self.data_source)
  
      class TestModel(BoringModel):
          def train_dataloader(self):
              dataset = RandomDataset(32, 64)
              sampler = NonSequentialSampler(dataset)
              return torch.utils.data.DataLoader(
                  dataset, sampler=sampler
              )
  
          def val_dataloader(self):
              dataset = RandomDataset(32, 64)
              sampler = NonSequentialSampler(dataset)
              return torch.utils.data.DataLoader(
                  dataset, sampler=sampler
              )
  
      model = TestModel()
      trainer = Trainer(
          default_root_dir=tmpdir, max_epochs=1, overfit_batches=2
      )
  
      with pytest.warns(
          UserWarning,
          match="requested to overfit but enabled train dataloader shuffling",
      ):
          trainer.fit(model)
  
      assert isinstance(
          trainer.train_dataloader.sampler, SequentialSampler
      )
      assert isinstance(
          trainer.val_dataloaders.sampler, SequentialSampler
      )
  
file_path: pytorch-lightning/tests/tests_pytorch/trainer/flags/test_overfit_batches.py
imports: import os
  from unittest import mock
  import pytest
  import torch
  from lightning.pytorch import Trainer
  from lightning.pytorch.demos.boring_classes import BoringModel, RandomDataset
  from lightning.pytorch.trainer.states import RunningStage
  from torch.utils.data import DataLoader, DistributedSampler, RandomSampler, Sampler, SequentialSampler
  from tests_pytorch.helpers.datamodules import ClassifDataModule
  from tests_pytorch.helpers.datasets import SklearnDataset
  from tests_pytorch.helpers.runif import RunIf
  from tests_pytorch.helpers.simple_models import ClassificationModel
label_desc: Use image node_id 2 for calling a global function with example usage: test_overfit_batches_raises_warning_in_case_of_sequential_sampler(tmpdir) and returns: iter, len, torch, torch