code: def BagRELoader(
      path,
      rel2id,
      tokenizer,
      batch_size,
      shuffle,
      entpair_as_bag=False,
      bag_size=0,
      num_workers=8,
      collate_fn=BagREDataset.collate_fn,
  ):
      if bag_size == 0:
          collate_fn = BagREDataset.collate_fn
      else:
          collate_fn = BagREDataset.collate_bag_size_fn
      dataset = BagREDataset(
          path,
          rel2id,
          tokenizer,
          entpair_as_bag=entpair_as_bag,
          bag_size=bag_size,
      )
      data_loader = data.DataLoader(
          dataset=dataset,
          batch_size=batch_size,
          shuffle=shuffle,
          pin_memory=True,
          num_workers=num_workers,
          collate_fn=collate_fn,
      )
      return data_loader
  
imports: import torch
  import torch.utils.data
  import os, random, json, logging
  import numpy
  import sklearn.metrics
label_desc: Use image node_id 2 for calling a global function with example usage: BagRELoader(path, rel2id, tokenizer, batch_size, shuffle, entpair_as_bag, bag_size, num_workers, collate_fn) and returns: data_loader