code: def test_dm_init_from_datasets_with_init_params():
      """Test that extra kwargs can be passed down to the init via the ``LightningDataModule.from_datasets`` method.
  
      The two special arguments batch_size and num_workers get passed down depending on whether the __init__ accepts them.
  
      """
      # No additional parameters
      LightningDataModule.from_datasets(
          DummyDS(), batch_size=4, num_workers=2
      )
  
      class KnownExtraParametersDataModule(LightningDataModule):
          def __init__(self, batch_size=1, num_workers=0):
              super().__init__()
              self.batch_size = batch_size
              self.num_workers = num_workers
  
      # batch_size and num_workers get special treatment - they are part of the `from_datasets` signature
      dm = KnownExtraParametersDataModule.from_datasets(
          DummyDS(), batch_size=4, num_workers=2
      )
      assert dm.batch_size == 4
      assert dm.num_workers == 2
  
      class UnknownExtraParametersDataModule(LightningDataModule):
          def __init__(self, other, batch_size=1):
              super().__init__()
              self.other = other
              self.batch_size = batch_size
  
      # additional parameter `other` gets forwarded, alongside the special `batch_size` parameter
      dm = UnknownExtraParametersDataModule.from_datasets(
          DummyDS(), batch_size=4, num_workers=2, other=5
      )
      assert dm.batch_size == 4
      assert dm.other == 5
  
      # positional arguments raise an error as they would when instantiating the datamodule normally
      with pytest.raises(
          TypeError,
          match="missing 1 required positional argument: 'other'",
      ):
          UnknownExtraParametersDataModule.from_datasets(
              DummyDS(), batch_size=4, num_workers=2
          )
  
      class KwargsParametersDataModule(LightningDataModule):
          def __init__(self, num_workers, **kwargs):
              super().__init__()
              self.num_workers = num_workers
              for key, value in kwargs.items():
                  setattr(self, key, value)
  
      # everything gets forwarded, because there is `**kwargs` present
      dm = KwargsParametersDataModule.from_datasets(
          DummyDS(), batch_size=10, num_workers=100, another=None
      )
      assert dm.batch_size == 10
      assert dm.num_workers == 100
      assert dm.another is None
  
imports: import pickle
  from argparse import Namespace
  from dataclasses import dataclass
  from typing import Any, Dict
  from unittest import mock
  from unittest.mock import Mock, PropertyMock, call
  import pytest
  import torch
  from lightning.pytorch import LightningDataModule, Trainer, seed_everything
  from lightning.pytorch.callbacks import ModelCheckpoint
  from lightning.pytorch.demos.boring_classes import BoringDataModule, BoringModel
  from lightning.pytorch.profilers.simple import SimpleProfiler
  from lightning.pytorch.trainer.states import TrainerFn
  from lightning.pytorch.utilities import AttributeDict
  from lightning.pytorch.utilities.exceptions import MisconfigurationException
  from lightning.pytorch.utilities.imports import _OMEGACONF_AVAILABLE
  from tests_pytorch.helpers.datamodules import ClassifDataModule
  from tests_pytorch.helpers.runif import RunIf
  from tests_pytorch.helpers.simple_models import ClassificationModel
label_desc: Use image node_id 12 for calling a global function with example usage: test_dm_init_from_datasets_with_init_params() without return types