code: def example_hin_random(
      feature_size_by_type=None,
      nodes_by_type={},
      n_isolates_by_type={},
      edges_by_type={},
  ):
      """
      Create random heterogeneous graph
  
      Args:
          feature_size_by_type: Dict of node types to feature size
          nodes_by_type: Dict of node types to number of nodes
          n_isolates_by_type: Dict of node types to number of isolates
          edges_by_type: Dict of edge types to number of edges
  
      Returns:
          StellarGraph
          Dictionary of node type to node labels
      """
      check_isolates = False
      while not check_isolates:
          G = nx.Graph()
          node_dict = {}
          for nt in nodes_by_type:
              nodes = [
                  "{}_{}".format(nt, ii)
                  for ii in range(nodes_by_type[nt])
              ]
              node_dict[nt] = nodes
              G.add_nodes_from(nodes, label=nt)
  
          for nt1, nt2 in edges_by_type:
              nodes1 = node_dict[nt1]
              nodes2 = node_dict[nt2]
  
              niso1 = n_isolates_by_type.get(nt1, 0)
              niso2 = n_isolates_by_type.get(nt2, 0)
              nodes1 = nodes1[:-niso1] if niso1 > 0 else nodes1
              nodes2 = nodes2[:-niso2] if niso2 > 0 else nodes1
  
              edges = [
                  (random.choice(nodes1), random.choice(nodes2))
                  for _ in range(edges_by_type[(nt1, nt2)])
              ]
              G.add_edges_from(edges, label="{}_{}".format(nt1, nt2))
  
          check_isolates = all(
              sum(deg[1] == 0 for deg in nx.degree(G, nodes))
              == n_isolates_by_type[nt]
              for nt, nodes in node_dict.items()
          )
  
      # Add example features
      if feature_size_by_type is not None:
          nt_jj = 0
          for nt, nodes in node_dict.items():
              for ii, n in enumerate(nodes):
                  G.nodes[n]["feature"] = (ii + 10 * nt_jj) * np.ones(
                      feature_size_by_type[nt], dtype="int"
                  )
              nt_jj += 1
  
          G = StellarGraph.from_networkx(G, node_features="feature")
  
      else:
          G = StellarGraph.from_networkx(G)
  
      return G, node_dict
  
imports: import numpy
  import networkx
  import pytest
  import random
  from stellargraph.mapper import *
  from stellargraph.core.graph import *
  from stellargraph.data.unsupervised_sampler import *
  from ..test_utils.graphs import example_graph, example_graph_random, example_hin_1, repeated_features, weighted_tree
  from ..None import test_utils
label_desc: Use image node_id 2 for calling a global function with example usage: example_hin_random(feature_size_by_type, nodes_by_type, n_isolates_by_type, edges_by_type) and returns: G,  node_dict