code: def __iter__(self):
      # the magic number comes from the author's code
      perm = torch.randperm(len(self.data_source))
      lens = torch.Tensor([len(x) for x in self.data_source])
      lens = lens[perm]
      t1 = []
      t2 = []
      t3 = []
      for i, l in enumerate(lens):
          if l < 100:
              t1.append(perm[i])
          elif l > 100 and l < 220:
              t2.append(perm[i])
          else:
              t3.append(perm[i])
      datas = [t1, t2, t3]
      random.shuffle(datas)
      idxs = sum(datas, [])
      batch = []
  
      lens = torch.Tensor([len(x) for x in self.data_source])
      for idx in idxs:
          batch.append(idx)
          mlen = max([0] + [lens[x] for x in batch])
          if (
              (mlen < 100 and len(batch) == 32)
              or (mlen > 100 and mlen < 220 and len(batch) >= 24)
              or (mlen > 220 and len(batch) >= 8)
              or len(batch) == 32
          ):
              yield batch
              batch = []
      if len(batch) > 0:
          yield batch
  
imports: import json
  import pickle
  import random
  import dgl
  import numpy
  import torch
label_desc: Use image node_id 2 for calling the BucketSampler obj's underlying member method code with example usage: obj.__iter__() without return types