class_docstr: HALK walking strategy which removes rare vertices from randomly
  extracted walks, increasing the quality of the generated embeddings while
  memory usage decreases.
  
  Attributes:
      _is_support_remote: True if the walking strategy can be used with a
          remote Knowledge Graph, False Otherwise
          Defaults to True.
      freq_thresholds: The minimum frequency thresholds of a (predicate,
          object) hop to be kept. Beware that the accumulation of several
          freq_thresholds extracts more walks, which is not always desirable.
          Defaults to [0.01].
      kg: The global KG used later on for the worker process.
          Defaults to None.
      max_depth: The maximum depth of one walk.
      max_walks: The maximum number of walks per entity.
          Defaults to None.
      md5_bytes: The number of bytes to keep after hashing objects in
          MD5. Hasher allows to reduce the memory occupied by a long text. If
          md5_bytes is None, no hash is applied.
          Defaults to 8.
      random_state: The random state to use to keep random determinism with
          the walking strategy.
          Defaults to None.
      sampler: The sampling strategy.
          Defaults to UniformSampler.
      with_reverse: True to extracts parents and children hops from an
          entity, creating (max_walks * max_walks) walks of 2 * depth,
          allowing also to centralize this entity in the walks. False
          otherwise.
          Defaults to False.
class_docstr_tok: ["HALK","walking","strategy","which","removes","rare","vertices","from","randomly","extracted","walks",",","increasing","the","quality","of","the","generated","embeddings","while","memory","usage","decreases",".","Attributes",":","_is_support_remote",":","True","if","the","walking","strategy","can","be","used","with","a","remote","Knowledge","Graph",",","False","Otherwise","Defaults","to","True",".","freq_thresholds",":","The","minimum","frequency","thresholds","of","a","(","predicate",",","object",")","hop","to","be","kept",".","Beware","that","the","accumulation","of","several","freq_thresholds","extracts","more","walks",",","which","is","not","always","desirable",".","Defaults","to","[","0.01","]",".","kg",":","The","global","KG","used","later","on","for","the","worker","process",".","Defaults","to","None",".","max_depth",":","The","maximum","depth","of","one","walk",".","max_walks",":","The","maximum","number","of","walks","per","entity",".","Defaults","to","None",".","md5_bytes",":","The","number","of","bytes","to","keep","after","hashing","objects","in","MD5",".","Hasher","allows","to","reduce","the","memory","occupied","by","a","long","text",".","If","md5_bytes","is","None",",","no","hash","is","applied",".","Defaults","to","8.","random_state",":","The","random","state","to","use","to","keep","random","determinism","with","the","walking","strategy",".","Defaults","to","None",".","sampler",":","The","sampling","strategy",".","Defaults","to","UniformSampler",".","with_reverse",":","True","to","extracts","parents","and","children","hops","from","an","entity",",","creating","(","max_walks","*","max_walks",")","walks","of","2","*","depth",",","allowing","also","to","centralize","this","entity","in","the","walks",".","False","otherwise",".","Defaults","to","False","."]
docstr: Post processed walks.
  
  Args:
      res: the result of the walks extracted with multiprocessing.
  
  Returns:
      The 2D matrix with its number of rows equal to the number of
      provided entities; number of column equal to the embedding size.
docstr_tok: ["Post","processed","walks",".","Args",":","res",":","the","result","of","the","walks","extracted","with","multiprocessing",".","Returns",":","The","2D","matrix","with","its","number","of","rows","equal","to","the","number","of","provided","entities",";","number","of","column","equal","to","the","embedding","size","."]
code: def _post_extract(self, res: List[EntityWalks]) -> List[List[SWalk]]:
      """Post processed walks.
  
      Args:
          res: the result of the walks extracted with multiprocessing.
  
      Returns:
          The 2D matrix with its number of rows equal to the number of
          provided entities; number of column equal to the embedding size.
  
      """
      conv_res = list(
          walks
          for entity_to_walks in res
          for walks in entity_to_walks.values()
      )
      walks: List[SWalk] = [
          walk for entity_walks in conv_res for walk in entity_walks
      ]
  
      predicates_dict = self.build_dictionary(walks)
      pred_thresholds = [
          self.get_rare_predicates(
              predicates_dict, walks, freq_threshold
          )
          for freq_threshold in self.freq_thresholds
      ]
      res_halk = []
      for rare_predicates in pred_thresholds:
          for entity_walks in conv_res:
              canonical_walks = []
              if not self.with_reverse:
                  curr_entity = entity_walks[0][0]
              else:
                  curr_walk = list(entity_walks[0])
                  curr_entity = curr_walk[
                      math.trunc(len(curr_walk) / 2)
                  ]
              for walk in entity_walks:
                  if not self.with_reverse:
                      canonical_walk = [curr_entity]
                  else:
                      canonical_walk = [walk[0]]
                  reverse = True
                  j = 0
                  for i, vertex in enumerate(walk[1::2], 2):
                      if vertex not in rare_predicates:
                          if self.with_reverse:
                              obj = walk[i + j]
                              j += 1
                          else:
                              obj = (
                                  walk[i] if i % 2 == 0 else walk[i + 1]
                              )
                          if self.with_reverse and reverse:
                              if obj == curr_entity:
                                  reverse = False
                          canonical_walk += [vertex, obj]
                  if len(canonical_walk) >= 3:
                      canonical_walks.append(tuple(canonical_walk))
              if canonical_walks:
                  res_halk.append(canonical_walks)
              else:
                  res_halk.append([(curr_entity,)])
      return res_halk
  
file_path: pyRDF2Vec/pyrdf2vec/walkers/halk.py
imports: import itertools
  import math
  from collections import defaultdict
  from typing import DefaultDict, List, Set
  import attr
  from pyrdf2vec.graphs import KG, Vertex
  from pyrdf2vec.typings import EntityWalks, SWalk
  from pyrdf2vec.walkers import RandomWalker
label_desc: Use image node_id 4 for calling the HALKWalker obj's underlying member method code with example usage: obj._post_extract(res) and returns: res_halk