code: def collate_from_data_or_kwargs(data, kwargs):
      if "collate_fn" in kwargs:
          return
      elif hasattr(data, "collate_fn"):
          kwargs["collate_fn"] = data.collate_fn
  
imports: from typing import Any, Dict, Iterator, List, Optional, Sequence, Sized, Union
  import numpy
  from torch.utils.data import DistributedSampler, Dataset
  from torch.utils.data.dataloader import DataLoader
  from avalanche.benchmarks.utils.data import AvalancheDataset
  from avalanche.benchmarks.utils.data_attribute import DataAttribute
  from avalanche.benchmarks.utils.ffcv_support.ffcv_components import HybridFfcvLoader, has_ffcv_support
  from avalanche.distributed.distributed_helper import DistributedHelper
  from torch.utils.data.sampler import Sampler, BatchSampler
  from torch.utils.data import ConcatDataset
label_desc: Use image node_id 2 for calling a global function with example usage: collate_from_data_or_kwargs(data, kwargs) without return types