code: def bb_pad_collate(samples:BatchSamples, pad_idx:int=0) -> Tuple[FloatTensor, Tuple[LongTensor, LongTensor]]:
      "Function that collect `samples` of labelled bboxes and adds padding with `pad_idx`."
      if isinstance(samples[0][1], int): return data_collate(samples)
      max_len = max([len(s[1].data[1]) for s in samples])
      bboxes = torch.zeros(len(samples), max_len, 4)
      labels = torch.zeros(len(samples), max_len).long() + pad_idx
      imgs = []
      for i,s in enumerate(samples):
          imgs.append(s[0].data[None])
          bbs, lbls = s[1].data
          if not (bbs.nelement() == 0):
              bboxes[i,-len(lbls):] = bbs
              labels[i,-len(lbls):] = tensor(lbls)
      return torch.cat(imgs,0), (bboxes,labelsf bb_pad_collate(samples:BatchSamples, pad_idx:int=0) -> Tuple[FloatTensor, Tuple[LongTensor, LongTensor]]:
      "Function that collect `samples` of labelled bboxes and adds padding with `pad_idx`."
      if isinstance(samples[0][1], int): return data_collate(samples)
      max_len = max([len(s[1].data[1]) for s in samples])
      bboxes = torch.zeros(len(samples), max_len, 4)
      labels = torch.zeros(len(samples), max_len).long() + pad_idx
      imgs = []
      for i,s in enumerate(samples):
          imgs.append(s[0].data[None])
          bbs, lbls = s[1].data
          if not (bbs.nelement() == 0):
              bboxes[i,-len(lbls):] = bbs
              labels[i,-len(lbls):] = tensor(lbls)
      return torch.cat(imgs,0), (bboxes,labels)
docs: Function that collect `samples` of labelled bboxes and adds padding with `pad_idx`.