code: def get_edge_idx_type(
      graph, graph_idx, rel2idx, include_reverse_relations=False
  ):
      # Return from a graph, the required edge_index and edge_type info
      # Pretty simple since from graph_idx
      edge_index = np.array(list(graph_idx.edges)).T
  
      # For type, need to do a conversion
      edge_type = [graph.edges[e]["relation"] for e in graph.edges]
      edge_type = np.array([rel2idx[rel] for rel in edge_type])
  
      # Add reverse relations
      if include_reverse_relations:
          edge_src = np.expand_dims(edge_index[0, :], 0)
          edge_dest = np.expand_dims(edge_index[1, :], 0)
          edge_reverse = np.concatenate([edge_dest, edge_src], axis=0)
          edge_index = np.concatenate(
              [edge_index, edge_reverse], axis=1
          )
  
      return edge_index, edge_type
  
imports: import os
  import pickle
  import networkx
  import numpy
  import torch
  import torch.nn
  import torch.nn.functional
  from gensim.models import KeyedVectors
  from gensim.scripts.glove2word2vec import glove2word2vec
  from mmf.common.registry import registry
  from mmf.models.base_model import BaseModel
  from mmf.utils.text import VocabDict
  from networkx import convert_node_labels_to_integers
  from torch_geometric.nn import BatchNorm, GCNConv, RGCNConv, SAGEConv
  from tqdm import tqdm
label_desc: Use image node_id 3 for calling a global function with example usage: get_edge_idx_type(graph, graph_idx, rel2idx, include_reverse_relations) and returns: edge_index,  edge_type