code: def _call_lightning_datamodule_hook(
      trainer: "pl.Trainer",
      hook_name: str,
      *args: Any,
      **kwargs: Any,
  ) -> Any:
      log.debug(
          f"{trainer.__class__.__name__}: calling lightning datamodule hook: {hook_name}"
      )
  
      if trainer.datamodule is None:
          raise TypeError(
              "No `LightningDataModule` is available to call hooks on."
          )
  
      fn = getattr(trainer.datamodule, hook_name)
      if callable(fn):
          with trainer.profiler.profile(
              f"[LightningDataModule]{trainer.datamodule.__class__.__name__}.{hook_name}"
          ):
              return fn(*args, **kwargs)
      return None
  
imports: import logging
  from copy import deepcopy
  from typing import Any, Callable, Dict, Optional, Type, Union
  from packaging.version import Version
  import lightning.pytorch
  from lightning.fabric.utilities.device_dtype_mixin import _DeviceDtypeModuleMixin
  from lightning.pytorch.callbacks import Checkpoint, EarlyStopping
  from lightning.pytorch.trainer.states import TrainerStatus
  from lightning.pytorch.utilities.exceptions import _TunerExitException
  from lightning.pytorch.utilities.model_helpers import is_overridden
  from lightning.pytorch.utilities.rank_zero import rank_zero_warn
label_desc: Use image node_id 6 for calling a global function with example usage: _call_lightning_datamodule_hook(trainer, hook_name) and returns: None, fn