class_docstr: Base class of the sampling strategies.
  
  Attributes:
      _is_support_remote: True if the sampling strategy can be used with a
          remote Knowledge Graph, False Otherwise
          Defaults to False.
      _random_state: The random state to use to keep random determinism with
          the sampling strategy.
          Defaults to None.
      _vertices_deg: The degree of the vertices.
          Defaults to {}.
      _visited: Tags vertices that appear at the max depth or of which all
          their children are tagged.
          Defaults to set.
      inverse: True if the inverse algorithm must be used, False otherwise.
          Defaults to False.
      split: True if the split algorithm must be used, False otherwise.
          Defaults to False.
class_docstr_tok: ["Base","class","of","the","sampling","strategies",".","Attributes",":","_is_support_remote",":","True","if","the","sampling","strategy","can","be","used","with","a","remote","Knowledge","Graph",",","False","Otherwise","Defaults","to","False",".","_random_state",":","The","random","state","to","use","to","keep","random","determinism","with","the","sampling","strategy",".","Defaults","to","None",".","_vertices_deg",":","The","degree","of","the","vertices",".","Defaults","to","{","}",".","_visited",":","Tags","vertices","that","appear","at","the","max","depth","or","of","which","all","their","children","are","tagged",".","Defaults","to","set",".","inverse",":","True","if","the","inverse","algorithm","must","be","used",",","False","otherwise",".","Defaults","to","False",".","split",":","True","if","the","split","algorithm","must","be","used",",","False","otherwise",".","Defaults","to","False","."]
docstr: Samples an unvisited random hop in the (predicate, object)
  form, according to the weight of hops for a given walk.
  
  Args:
      kg: The Knowledge Graph.
      walk: The walk with one or several vertices.
      is_last_hop: True if the next hop to be visited is the last
          one for the desired depth, False otherwise.
      is_reverse: True to get the parent neighbors instead of the child
          neighbors, False otherwise.
          Defaults to False.
  
  Returns:
      An unvisited hop in the (predicate, object) form.
docstr_tok: ["Samples","an","unvisited","random","hop","in","the","(","predicate",",","object",")","form",",","according","to","the","weight","of","hops","for","a","given","walk",".","Args",":","kg",":","The","Knowledge","Graph",".","walk",":","The","walk","with","one","or","several","vertices",".","is_last_hop",":","True","if","the","next","hop","to","be","visited","is","the","last","one","for","the","desired","depth",",","False","otherwise",".","is_reverse",":","True","to","get","the","parent","neighbors","instead","of","the","child","neighbors",",","False","otherwise",".","Defaults","to","False",".","Returns",":","An","unvisited","hop","in","the","(","predicate",",","object",")","form","."]
code: def sample_hop(
      self,
      kg: KG,
      walk: Walk,
      is_last_hop: bool,
      is_reverse: bool = False,
  ) -> Optional[Hop]:
      """Samples an unvisited random hop in the (predicate, object)
      form, according to the weight of hops for a given walk.
  
      Args:
          kg: The Knowledge Graph.
          walk: The walk with one or several vertices.
          is_last_hop: True if the next hop to be visited is the last
              one for the desired depth, False otherwise.
          is_reverse: True to get the parent neighbors instead of the child
              neighbors, False otherwise.
              Defaults to False.
  
      Returns:
          An unvisited hop in the (predicate, object) form.
  
      """
      subj = walk[0] if is_reverse else walk[-1]
  
      untagged_neighbors = [
          pred_obj
          for pred_obj in kg.get_hops(subj, is_reverse)
          if (pred_obj, len(walk)) not in self.visited
      ]
  
      if len(untagged_neighbors) == 0:
          if len(walk) > 2:
              pred_obj = (
                  (walk[1], walk[0])
                  if is_reverse
                  else (walk[-2], walk[-1])
              )
              self.visited.add((pred_obj, len(walk) - 2))
          return None
  
      rnd_id = np.random.RandomState(self._random_state).choice(
          range(len(untagged_neighbors)),
          p=self.get_weights(untagged_neighbors),
      )
  
      if is_last_hop:
          self.visited.add((untagged_neighbors[rnd_id], len(walk)))
      return untagged_neighbors[rnd_id]
  
file_path: pyRDF2Vec/pyrdf2vec/samplers/sampler.py
imports: import random
  from abc import ABC, abstractmethod
  from typing import Dict, List, Optional, Set, Tuple
  import attr
  import numpy
  from pyrdf2vec.graphs import KG
  from pyrdf2vec.typings import Hop, Walk
label_desc: Use image node_id 4 for calling the Sampler obj's underlying member method code with example usage: obj.sample_hop(kg, walk, is_last_hop, is_reverse) and returns: untagged_neighbors, None