class_docstr: Class to encapsulate the schema information for a heterogeneous graph.
  
  Typically this should be created from a StellarGraph object, using the
  :func:`~stellargraph.core.graph.create_graph_schema` method.
class_docstr_tok: ["Class","to","encapsulate","the","schema","information","for","a","heterogeneous","graph",".","Typically","this","should","be","created","from","a","StellarGraph","object",",","using","the",":","func",":","`","~stellargraph.core.graph.create_graph_schema","`","method","."]
docstr: For a sampling scheme with a list of head node types and the
  number of samples per hop, return the map from the actual
  sample index to the adjacency list index.
  
  Args:
      head_node_types: A list of node types of the head nodes.
      num_samples: A list of integers that are the number of neighbours
                   to sample at each hop.
  
  Returns:
      A list containing, for each head node type, a list consisting of
      tuples of (node_type, sampling_index). The list matches the
      list given by the method `type_adjacency_list(...)` and can be
      used to reformat the samples given by `SampledBreadthFirstWalk` to
      that expected by the HinSAGE model.
docstr_tok: ["For","a","sampling","scheme","with","a","list","of","head","node","types","and","the","number","of","samples","per","hop",",","return","the","map","from","the","actual","sample","index","to","the","adjacency","list","index",".","Args",":","head_node_types",":","A","list","of","node","types","of","the","head","nodes",".","num_samples",":","A","list","of","integers","that","are","the","number","of","neighbours","to","sample","at","each","hop",".","Returns",":","A","list","containing",",","for","each","head","node","type",",","a","list","consisting","of","tuples","of","(","node_type",",","sampling_index",")",".","The","list","matches","the","list","given","by","the","method","`","type_adjacency_list","(","...",")","`","and","can","be","used","to","reformat","the","samples","given","by","`","SampledBreadthFirstWalk","`","to","that","expected","by","the","HinSAGE","model","."]
code: def sampling_layout(self, head_node_types, num_samples):
      """
      For a sampling scheme with a list of head node types and the
      number of samples per hop, return the map from the actual
      sample index to the adjacency list index.
  
      Args:
          head_node_types: A list of node types of the head nodes.
          num_samples: A list of integers that are the number of neighbours
                       to sample at each hop.
  
      Returns:
          A list containing, for each head node type, a list consisting of
          tuples of (node_type, sampling_index). The list matches the
          list given by the method `type_adjacency_list(...)` and can be
          used to reformat the samples given by `SampledBreadthFirstWalk` to
          that expected by the HinSAGE model.
      """
      adjacency_list = self.type_adjacency_list(
          head_node_types, len(num_samples)
      )
      sample_index_layout = []
      sample_inverse_layout = []
  
      # The head nodes are the first K nodes in the adjacency list
      # TODO: generalize this?
      for ii, hnt in enumerate(head_node_types):
          adj_to_samples = [(adj[0], []) for adj in adjacency_list]
  
          # The head nodes will be the first sample in the appropriate
          # sampling list, and the ii-th in the adjacenecy list
          sample_to_adj = {0: ii}
          adj_to_samples[ii][1].append(0)
  
          # Set the start group as the head node and point the index to the next hop
          node_groups = [(ii, hnt)]
          sample_index = 1
  
          # Iterate over all hops
          for jj, nsamples in enumerate(num_samples):
              next_node_groups = []
              for a_key, nt1 in node_groups:
                  # For each node we sample from all edge types from that node
                  edge_types = self.schema[nt1]
  
                  # We want to place the samples for these edge types in the correct
                  # place in the adjacency list
                  next_keys = adjacency_list[a_key][1]
  
                  for et, next_key in zip(edge_types, next_keys):
                      # These are psueo-samples for each edge type
                      sample_types = [(next_key, et.n2)] * nsamples
                      next_node_groups.extend(sample_types)
  
                      # Store the node type, adjacency and sampling indices
                      sample_to_adj[sample_index] = next_key
                      adj_to_samples[next_key][1].append(sample_index)
                      sample_index += 1
  
                      # Sanity check
                      assert adj_to_samples[next_key][0] == et.n2
  
              node_groups = next_node_groups
  
          # Add samples to layout and inverse layout
          sample_index_layout.append(sample_to_adj)
          sample_inverse_layout.append(adj_to_samples)
      return sample_inverse_layout
  
file_path: stellargraph/stellargraph/core/schema.py
imports: import queue
  import warnings
  from collections.__init__ import namedtuple
  from ..core.utils import is_real_iterable
label_desc: Use image node_id 7 for calling the GraphSchema obj's underlying member method code with example usage: obj.sampling_layout(head_node_types, num_samples) and returns: sample_inverse_layout