class_docstr: unittest for NetworkMorphismTuner
      
class_docstr_tok: ["unittest","for","NetworkMorphismTuner"]
docstr: unittest for graph_json_transform function
          
docstr_tok: ["unittest","for","graph_json_transform","function"]
code: def test_graph_json_transform(self):
      """unittest for graph_json_transform function"""
  
      graph_init = CnnGenerator(10, (32, 32, 3)).generate()
      graph_init = to_wider_graph(deepcopy(graph_init))
      graph_init = to_deeper_graph(deepcopy(graph_init))
      graph_init = to_skip_connection_graph(deepcopy(graph_init))
      json_out = graph_to_json(graph_init, "temp.json")
  
      graph_recover = json_to_graph(json_out)
  
      # compare all data in graph
      self.assertEqual(
          graph_init.input_shape, graph_recover.input_shape
      )
      self.assertEqual(graph_init.weighted, graph_recover.weighted)
      self.assertEqual(
          graph_init.layer_id_to_input_node_ids,
          graph_recover.layer_id_to_input_node_ids,
      )
      self.assertEqual(graph_init.adj_list, graph_recover.adj_list)
      self.assertEqual(
          graph_init.reverse_adj_list, graph_recover.reverse_adj_list
      )
      self.assertEqual(
          len(graph_init.operation_history),
          len(graph_recover.operation_history),
      )
      self.assertEqual(graph_init.n_dim, graph_recover.n_dim)
      self.assertEqual(graph_init.conv, graph_recover.conv)
      self.assertEqual(graph_init.batch_norm, graph_recover.batch_norm)
      self.assertEqual(graph_init.vis, graph_recover.vis)
  
      node_list_init = [node.shape for node in graph_init.node_list]
      node_list_recover = [
          node.shape for node in graph_recover.node_list
      ]
      self.assertEqual(node_list_init, node_list_recover)
      self.assertEqual(
          len(graph_init.node_to_id), len(graph_recover.node_to_id)
      )
      layer_list_init = [
          layer_description_extractor(item, graph_init.node_to_id)
          for item in graph_init.layer_list
      ]
      layer_list_recover = [
          layer_description_extractor(item, graph_recover.node_to_id)
          for item in graph_recover.layer_list
      ]
      self.assertEqual(layer_list_init, layer_list_recover)
  
      node_to_id_init = [
          graph_init.node_to_id[node] for node in graph_init.node_list
      ]
      node_to_id_recover = [
          graph_recover.node_to_id[node]
          for node in graph_recover.node_list
      ]
      self.assertEqual(node_to_id_init, node_to_id_recover)
  
      layer_to_id_init = [
          graph_init.layer_to_id[layer]
          for layer in graph_init.layer_list
      ]
      layer_to_id_recover = [
          graph_recover.layer_to_id[layer]
          for layer in graph_recover.layer_list
      ]
      self.assertEqual(layer_to_id_init, layer_to_id_recover)
  
imports: import json
  from unittest import TestCase, main
  from copy import deepcopy
  import torch
  from nni.algorithms.hpo.networkmorphism_tuner import NetworkMorphismTuner
  from nni.algorithms.hpo.networkmorphism_tuner.graph import graph_to_json, json_to_graph
  from nni.algorithms.hpo.networkmorphism_tuner.graph_transformer import to_deeper_graph, to_skip_connection_graph, to_wider_graph
  from nni.algorithms.hpo.networkmorphism_tuner.layers import layer_description_extractor
  from nni.algorithms.hpo.networkmorphism_tuner.nn import CnnGenerator
label_desc: Use image node_id 1 for calling the NetworkMorphismTestCase obj's underlying member method code with example usage: obj.test_graph_json_transform() without return types