code: def random_subset(
      dataset, max_samples: int, seed: int = 42
  ) -> torch.utils.data.Subset:
      if max_samples >= len(dataset):
          return dataset
  
      generator = torch.Generator().manual_seed(seed)
      perm = torch.randperm(len(dataset), generator=generator)
      return torch.utils.data.Subset(
          dataset, perm[:max_samples].tolist()
      )
  
imports: from concurrent.futures import ProcessPoolExecutor
  from contextlib import contextmanager
  from functools import wraps, lru_cache
  import hashlib
  import json
  import logging
  from pathlib import Path
  import typing
  import flashy
  import flashy.distrib
  import omegaconf
  import torch
  from torch.nn.utils.rnn import pad_sequence
label_desc: Use image node_id 3 for calling a global function with example usage: random_subset(dataset, max_samples, seed) and returns: torch, dataset