code: def train_val_split(dataset: Dataset, val_size: float = 0.1):
      L = len(dataset)
      train_size = int(L * (1 - val_size))
      val_size = L - train_size
      return random_split(
          dataset,
          [train_size, val_size],
          generator=torch.Generator().manual_seed(42),
      )
  
imports: import warnings
  from typing import Any, Callable, Dict, List, Optional
  import numpy
  import torch
  from torch import Tensor
  from torch.utils.data import DataLoader, Dataset, random_split
  from flash.core.data.data_module import DataModule
  from flash.core.data.io.input import InputBase
  from flash.core.data.io.input_transform import create_worker_input_transform_processor
  from flash.core.utilities.imports import _BAAL_AVAILABLE, requires
  from flash.core.utilities.stages import RunningStage
label_desc: Use image node_id 3 for calling a global function with example usage: train_val_split(dataset, val_size) and returns: random_split