code: def test_to_from_lisrel(self):
      demo_lisrel = self.demo.to_lisrel()
      union_lisrel = self.union.to_lisrel()
      demo_params_lisrel = self.demo_params.to_lisrel()
      custom_lisrel = self.custom.to_lisrel()
  
      demo_graph = demo_lisrel.to_SEMGraph()
      union_graph = union_lisrel.to_SEMGraph()
      demo_params_graph = demo_params_lisrel.to_SEMGraph()
      custom_graph = custom_lisrel.to_SEMGraph()
  
      # Test demo
      self.assertSetEqual(
          set(self.demo.graph.nodes()), set(demo_graph.graph.nodes())
      )
      self.assertSetEqual(
          set(self.demo.graph.edges()), set(demo_graph.graph.edges())
      )
  
      self.assertSetEqual(
          set(self.demo.err_graph.nodes()),
          set(demo_graph.err_graph.nodes()),
      )
      npt.assert_array_equal(
          nx.to_numpy_array(
              self.demo.err_graph,
              nodelist=sorted(self.demo.err_graph.nodes()),
          ),
          nx.to_numpy_array(
              demo_graph.err_graph,
              nodelist=sorted(demo_graph.err_graph.nodes()),
          ),
      )
  
      self.assertSetEqual(
          set(self.demo.full_graph_struct.nodes()),
          set(demo_graph.full_graph_struct.nodes()),
      )
      self.assertSetEqual(
          set(self.demo.full_graph_struct.edges()),
          set(demo_graph.full_graph_struct.edges()),
      )
  
      self.assertSetEqual(self.demo.latents, demo_graph.latents)
      self.assertSetEqual(self.demo.observed, demo_graph.observed)
  
      # Test union
      self.assertSetEqual(
          set(self.union.graph.nodes()), set(union_graph.graph.nodes())
      )
      self.assertSetEqual(
          set(self.union.graph.edges()), set(union_graph.graph.edges())
      )
  
      self.assertSetEqual(
          set(self.union.err_graph.nodes()),
          set(union_graph.err_graph.nodes()),
      )
      npt.assert_array_equal(
          nx.to_numpy_array(
              self.union.err_graph,
              nodelist=sorted(self.union.err_graph.nodes()),
          ),
          nx.to_numpy_array(
              union_graph.err_graph,
              nodelist=sorted(union_graph.err_graph.nodes()),
          ),
      )
  
      self.assertSetEqual(
          set(self.union.full_graph_struct.nodes()),
          set(union_graph.full_graph_struct.nodes()),
      )
      self.assertSetEqual(
          set(self.union.full_graph_struct.edges()),
          set(union_graph.full_graph_struct.edges()),
      )
  
      self.assertSetEqual(self.union.latents, union_graph.latents)
      self.assertSetEqual(self.union.observed, union_graph.observed)
  
      # Test demo_params
      self.assertSetEqual(
          set(self.demo_params.graph.nodes()),
          set(demo_params_graph.graph.nodes()),
      )
      self.assertSetEqual(
          set(self.demo_params.graph.edges()),
          set(demo_params_graph.graph.edges()),
      )
  
      self.assertSetEqual(
          set(self.demo_params.err_graph.nodes()),
          set(demo_params_graph.err_graph.nodes()),
      )
      npt.assert_array_equal(
          nx.to_numpy_array(
              self.demo_params.err_graph,
              nodelist=sorted(self.demo_params.err_graph.nodes()),
              weight=None,
          ),
          nx.to_numpy_array(
              demo_graph.err_graph,
              nodelist=sorted(demo_params_graph.err_graph.nodes()),
              weight=None,
          ),
      )
  
      self.assertSetEqual(
          set(self.demo_params.full_graph_struct.nodes()),
          set(demo_params_graph.full_graph_struct.nodes()),
      )
      self.assertSetEqual(
          set(self.demo_params.full_graph_struct.edges()),
          set(demo_params_graph.full_graph_struct.edges()),
      )
  
      self.assertSetEqual(
          self.demo_params.latents, demo_params_graph.latents
      )
      self.assertSetEqual(
          self.demo_params.observed, demo_params_graph.observed
      )
  
      # Test demo
      self.assertSetEqual(
          set(self.custom.graph.nodes()),
          set(custom_graph.graph.nodes()),
      )
      self.assertSetEqual(
          set(self.custom.graph.edges()),
          set(custom_graph.graph.edges()),
      )
  
      self.assertSetEqual(
          set(self.custom.err_graph.nodes()),
          set(custom_graph.err_graph.nodes()),
      )
      npt.assert_array_equal(
          nx.to_numpy_array(
              self.custom.err_graph,
              nodelist=sorted(self.custom.err_graph.nodes()),
          ),
          nx.to_numpy_array(
              custom_graph.err_graph,
              nodelist=sorted(custom_graph.err_graph.nodes()),
          ),
      )
  
      self.assertSetEqual(
          set(self.custom.full_graph_struct.nodes()),
          set(custom_graph.full_graph_struct.nodes()),
      )
      self.assertSetEqual(
          set(self.custom.full_graph_struct.edges()),
          set(custom_graph.full_graph_struct.edges()),
      )
  
      self.assertSetEqual(self.custom.latents, custom_graph.latents)
      self.assertSetEqual(self.custom.observed, custom_graph.observed)
  
imports: import os
  import unittest
  import networkx
  import numpy
  import numpy.testing
  from pgmpy.models import SEM, SEMAlg, SEMGraph
label_desc: Use image node_id 9 for calling the TestSEMGraph obj's underlying member method code with example usage: obj.test_to_from_lisrel() without return types