class_docstr: Training instances for the sLCWA.
class_docstr_tok: ["Training","instances","for","the","sLCWA","."]
docstr: Collate samples.
docstr_tok: ["Collate","samples","."]
code: def collate(samples: Iterable[SLCWASampleType]) -> SLCWABatch:
      """Collate samples."""
      # each shape: (1, 3), (1, k, 3), (1, k, 3)?
      positives, negatives, masks = zip(*samples)
      positives = torch.cat(positives, dim=0)
      negatives = torch.cat(negatives, dim=0)
      if masks[0] is None:
          assert all(m is None for m in masks)
          masks = None
      else:
          masks = torch.cat(masks, dim=0)
      return SLCWABatch(positives, negatives, masks)
  
imports: import math
  from abc import ABC, abstractmethod
  from typing import Callable, Generic, Iterable, Iterator, List, NamedTuple, Optional, Tuple, TypeVar
  import numpy
  import scipy.sparse
  import torch
  from class_resolver import HintOrType, OptionalKwargs
  from torch.utils import data
  from .utils import compute_compressed_adjacency_list
  from ..sampling import NegativeSampler, negative_sampler_resolver
  from ..typing import MappedTriples
label_desc: Use image node_id 4 for calling the SLCWAInstances obj's underlying member method code with example usage: obj.collate(samples) and returns: SLCWABatch