code: def process_in_batches(
      batch_size: int,
      model: MultiRelationEmbedder,
      batch_processor: "AbstractBatchProcessor",
      edges: EdgeList,
      indices: Optional[LongTensorType] = None,
      delay: float = 0.0,
  ) -> Stats:
      """Split lhs, rhs and rel in batches, process them and sum the stats
  
      If indices is not None, only operate on x[indices] for x = lhs, rhs and rel.
      If delay is positive, wait for that many seconds before starting.
      """
      if indices is not None:
          edges = edges[indices]
  
      time.sleep(delay)
  
      # FIXME: it's not really safe to do partial batches if num_batch_negs != 0
      # because partial batches will produce incorrect results, and if the
      # dataset per thread is very small then every batch may be partial. I don't
      # know of a perfect solution for this that doesn't introduce other biases...
  
      all_stats = []
  
      if model.num_dynamic_rels > 0:
          batcher = batch_edges_mix_relation_types
      else:
          batcher = batch_edges_group_by_relation_type
  
      for batch_edges in batcher(edges, batch_size=batch_size):
          all_stats.append(
              batch_processor.process_one_batch(model, batch_edges)
          )
  
      stats = Stats.sum(all_stats)
      return stats
  
file_path: PyTorch-BigGraph/torchbiggraph/batching.py
imports: import time
  from abc import ABC, abstractmethod
  from typing import Any, Callable, Dict, Iterable, List, Optional
  import torch
  from torchbiggraph.edgelist import EdgeList
  from torchbiggraph.losses import AbstractLossFunction
  from torchbiggraph.model import MultiRelationEmbedder, override_model, Scores
  from torchbiggraph.stats import Stats
  from torchbiggraph.types import LongTensorType
label_desc: Use image node_id 5 for calling a global function with example usage: process_in_batches(batch_size, model, batch_processor, edges, indices, delay) and returns: stats