class_docstr: This class extract relations, objects or triplets from Wikidata HDT file.
class_docstr_tok: ["This","class","extract","relations",",","objects","or","triplets","from","Wikidata","HDT","file","."]
code: def find_rels_2hop(self, entity_ids, rels_1hop):
      rels = []
      for entity_id in entity_ids:
          for rel_1hop in rels_1hop:
              triplets, cnt = self.document.search_triples(
                  f"{self.prefixes['entity']}/{entity_id}", rel_1hop, ""
              )
              triplets = [
                  triplet
                  for triplet in triplets
                  if triplet[2].startswith(self.prefixes["entity"])
              ]
              objects_1hop = [
                  triplet[2].split("/")[-1] for triplet in triplets
              ]
              triplets, cnt = self.document.search_triples(
                  "", rel_1hop, f"{self.prefixes['entity']}/{entity_id}"
              )
              triplets = [
                  triplet
                  for triplet in triplets
                  if triplet[0].startswith(self.prefixes["entity"])
              ]
              objects_1hop += [
                  triplet[0].split("/")[-1] for triplet in triplets
              ]
              for object_1hop in objects_1hop[:5]:
                  tr_2hop, cnt = self.document.search_triples(
                      f"{self.prefixes['entity']}/{object_1hop}", "", ""
                  )
                  rels_2hop = [
                      elem[1] for elem in tr_2hop if elem[1] != rel_1hop
                  ]
                  if self.used_rels:
                      rels_2hop = [
                          elem
                          for elem in rels_2hop
                          if elem.split("/")[-1] in self.used_rels
                      ]
                  rels += rels_2hop
                  tr_2hop, cnt = self.document.search_triples(
                      "", "", f"{self.prefixes['entity']}/{object_1hop}"
                  )
                  rels_2hop = [
                      elem[1] for elem in tr_2hop if elem[1] != rel_1hop
                  ]
                  if self.used_rels:
                      rels_2hop = [
                          elem
                          for elem in rels_2hop
                          if elem.split("/")[-1] in self.used_rels
                      ]
                  rels += rels_2hop
      rels = list(set(rels))
      return rels
  
imports: import datetime
  import re
  from collections import namedtuple
  from logging import getLogger
  from typing import List, Tuple, Dict, Any, Union
  from hdt import HDTDocument
  from deeppavlov.core.commands.utils import expand_path
  from deeppavlov.core.common.file import load_pickle, read_json
  from deeppavlov.core.common.registry import register
label_desc: Use image node_id 12 for calling the WikiParser obj's underlying member method code with example usage: obj.find_rels_2hop(entity_ids, rels_1hop) and returns: rels