code: def generate_edge_path_files(
      edge_file_in: Path,
      edge_path_out: Path,
      edge_storage: AbstractEdgeStorage,
      entities_by_type: Dict[str, Dictionary],
      relation_types: Dictionary,
      relation_configs: List[RelationSchema],
      dynamic_relations: bool,
      edgelist_reader: EdgelistReader,
      n_flush_edges: int = 100000,
  ) -> None:
      log(
          f"Preparing edge path {edge_path_out}, "
          f"out of the edges found in {edge_file_in}"
      )
      edge_storage.prepare()
  
      num_lhs_parts = max(
          entities_by_type[rconfig.lhs].num_parts
          for rconfig in relation_configs
      )
      num_rhs_parts = max(
          entities_by_type[rconfig.rhs].num_parts
          for rconfig in relation_configs
      )
  
      log(
          f"- Edges will be partitioned in {num_lhs_parts} x {num_rhs_parts} buckets."
      )
  
      processed = 0
      skipped = 0
      # We use an ExitStack in order to close the dynamically-created edge appenders.
      with ExitStack() as appender_stack:
          appenders: Dict[Tuple[int, int], AbstractEdgeAppender] = {}
          data: Dict[Tuple[int, int], List[Tuple[int, int, int]]] = {}
  
          for (
              lhs_word,
              rhs_word,
              rel_word,
              weight,
          ) in edgelist_reader.read(edge_file_in):
              if rel_word is None:
                  rel_id = 0
              else:
                  try:
                      rel_id = relation_types.get_id(rel_word)
                  except KeyError:
                      # Ignore edges whose relation type is not known.
                      skipped += 1
                      continue
  
              if dynamic_relations:
                  lhs_type = relation_configs[0].lhs
                  rhs_type = relation_configs[0].rhs
              else:
                  lhs_type = relation_configs[rel_id].lhs
                  rhs_type = relation_configs[rel_id].rhs
  
              try:
                  lhs_part, lhs_offset = entities_by_type[
                      lhs_type
                  ].get_partition(lhs_word)
                  rhs_part, rhs_offset = entities_by_type[
                      rhs_type
                  ].get_partition(rhs_word)
              except KeyError:
                  # Ignore edges whose entities are not known.
                  skipped += 1
                  continue
  
              if (lhs_part, rhs_part) not in appenders:
                  appenders[
                      lhs_part, rhs_part
                  ] = appender_stack.enter_context(
                      edge_storage.save_edges_by_appending(
                          lhs_part, rhs_part
                      )
                  )
                  data[lhs_part, rhs_part] = []
  
              part_data = data[lhs_part, rhs_part]
              part_data.append((lhs_offset, rhs_offset, rel_id, weight))
              if len(part_data) > n_flush_edges:
                  append_to_file(
                      part_data, appenders[lhs_part, rhs_part]
                  )
                  part_data.clear()
  
              processed = processed + 1
              if processed % 100000 == 0:
                  log(f"- Processed {processed} edges so far...")
  
          for (lhs_part, rhs_part), part_data in data.items():
              if len(part_data) > 0:
                  append_to_file(
                      part_data, appenders[lhs_part, rhs_part]
                  )
                  part_data.clear()
  
      log(f"- Processed {processed} edges in total")
      if skipped > 0:
          log(
              f"- Skipped {skipped} edges because their relation type or "
              f"entities were unknown (either not given in the config or "
              f"filtered out as too rare)."
          )
  
imports: import datetime
  import random
  from abc import ABC, abstractmethod
  from contextlib import ExitStack
  from pathlib import Path
  from typing import Any, Counter, Dict, Iterable, List, Optional, Tuple
  import torch
  from torchbiggraph.config import EntitySchema, RelationSchema
  from torchbiggraph.converters.dictionary import Dictionary
  from torchbiggraph.edgelist import EdgeList
  from torchbiggraph.entitylist import EntityList
  from torchbiggraph.graph_storages import AbstractEdgeAppender, AbstractEdgeStorage, AbstractEntityStorage, AbstractRelationTypeStorage, EDGE_STORAGES, ENTITY_STORAGES, RELATION_TYPE_STORAGES
  from torchbiggraph.types import UNPARTITIONED
label_desc: Use image node_id 6 for calling a global function with example usage: generate_edge_path_files(edge_file_in, edge_path_out, edge_storage, entities_by_type, relation_types, relation_configs, dynamic_relations, edgelist_reader, n_flush_edges) without return types