code: def batchify(samples, batch_size):
      """
      Batchfy samples with a batch size
      """
      num_samples = len(samples)
  
      list_samples_batches = []
  
      # if a sentence is too long, make itself a batch to avoid GPU OOM
      to_single_batch = []
      for i in range(0, len(samples)):
          if len(samples[i]["tokens"]) > 350:
              to_single_batch.append(i)
  
      for i in to_single_batch:
          logger.info(
              "Single batch sample: %s-%d",
              samples[i]["doc_key"],
              samples[i]["sentence_ix"],
          )
          list_samples_batches.append([samples[i]])
      samples = [
          sample
          for i, sample in enumerate(samples)
          if i not in to_single_batch
      ]
  
      for i in range(0, len(samples), batch_size):
          list_samples_batches.append(samples[i : i + batch_size])
  
      assert (
          sum([len(batch) for batch in list_samples_batches])
          == num_samples
      )
  
      return list_samples_batches
  
file_path: DeepKE/example/triple/PURE/models/entityUtils.py
imports: import numpy
  import json
  import logging
label_desc: Use image node_id 1 for calling a global function with example usage: batchify(samples, batch_size) and returns: list_samples_batches