code: def collect_relation_types(
      relation_configs: List[RelationSchema],
      edge_paths: List[Path],
      dynamic_relations: bool,
      edgelist_reader: EdgelistReader,
      relation_type_min_count: int,
  ) -> Dictionary:
      if dynamic_relations:
          log("Looking up relation types in the edge files...")
          counter: Counter[str] = Counter()
          for edgepath in edge_paths:
              for (
                  _lhs_word,
                  _rhs_word,
                  rel_word,
                  _weight_word,
              ) in edgelist_reader.read(edgepath):
                  if rel_word is None:
                      raise RuntimeError(
                          "Need to specify rel_col in dynamic mode."
                      )
                  counter[rel_word] += 1
  
          log(f"- Found {len(counter)} relation types")
          if relation_type_min_count > 0:
              log(
                  "- Removing the ones with fewer than "
                  f"{relation_type_min_count} occurrences..."
              )
              counter = Counter(
                  {
                      k: c
                      for k, c in counter.items()
                      if c >= relation_type_min_count
                  }
              )
              log(f"- Left with {len(counter)} relation types")
          log("- Shuffling them...")
          names = list(counter.keys())
          random.shuffle(names)
  
      else:
          names = [rconfig.name for rconfig in relation_configs]
          log(
              f"Using the {len(names)} relation types given in the config"
          )
  
      return Dictionary(names)
  
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 2 for calling a global function with example usage: collect_relation_types(relation_configs, edge_paths, dynamic_relations, edgelist_reader, relation_type_min_count) and returns: Dictionary