class_docstr: Class for representing Structural Equation Models. This class is a wrapper over
  `SEMGraph` and `SEMAlg` to provide a consistent API over the different representations.
  
  Attributes
  ----------
  model: SEMGraph instance
      A graphical representation of the model.
class_docstr_tok: ["Class","for","representing","Structural","Equation","Models",".","This","class","is","a","wrapper","over","`","SEMGraph","`","and","`","SEMAlg","`","to","provide","a","consistent","API","over","the","different","representations",".","Attributes","--","--","--","--","--","model",":","SEMGraph","instance","A","graphical","representation","of","the","model","."]
docstr: Initializes a `SEM` instance using LISREL notation. The LISREL notation is defined as:
  ..math::
  
      \mathbf{\eta} = \mathbf{B \eta} + \mathbf{\Gamma \xi} + mathbf{\zeta} \\
      \mathbf{y} = \mathbf{\wedge_y \eta} + \mathbf{\epsilon} \\
      \mathbf{x} = \mathbf{\wedge_x \xi} + \mathbf{\delta}
  
  where :math:`\mathbf{\eta}` is the set of endogenous variables, :math:`\mathbf{\xi}`
  is the set of exogeneous variables, :math:`\mathbf{y}` and :math:`\mathbf{x}` are the
  set of measurement variables for :math:`\mathbf{\eta}` and :math:`\mathbf{\xi}`
  respectively. :math:`\mathbf{\zeta}`, :math:`\mathbf{\epsilon}`, and :math:`\mathbf{\delta}`
  are the error terms for :math:`\mathbf{\eta}`, :math:`\mathbf{y}`, and :math:`\mathbf{x}`
  respectively.
  
  Parameters
  ----------
  str_model: str (default: None)
      A `lavaan` style multiline set of regression equation representing the model.
      Refer http://lavaan.ugent.be/tutorial/syntax1.html for details.
  
      If None requires `var_names` and `params` to be specified.
  
  var_names: dict (default: None)
      A dict with the keys: eta, xi, y, and x. Each keys should have a list as the value
      with the name of variables.
  
  params: dict (default: None)
      A dict of LISREL representation non-zero parameters. Must contain the following
      keys: B, gamma, wedge_y, wedge_x, phi, theta_e, theta_del, and psi.
  
      If None `str_model` must be specified.
  
  fixed_params: dict (default: None)
      A dict of fixed values for parameters. The shape of the parameters should be same
      as params.
  
      If None all the parameters are learnable.
  
  Returns
  -------
  pgmpy.models.SEM instance: An instance of the object with initalized values.
  
  Examples
  --------
  >>> from pgmpy.models import SEMAlg
  # TODO: Finish this example
docstr_tok: ["Initializes","a","`","SEM","`","instance","using","LISREL","notation",".","The","LISREL","notation","is","defined","as",":","..","math",":",":","\\mathbf","{","\\eta","}","=","\\mathbf","{","B","\\eta","}","+","\\mathbf","{","\\Gamma","\\xi","}","+","mathbf","{","\\zeta","}","\\\\","\\mathbf","{","y","}","=","\\mathbf","{","\\wedge_y","\\eta","}","+","\\mathbf","{","\\epsilon","}","\\\\","\\mathbf","{","x","}","=","\\mathbf","{","\\wedge_x","\\xi","}","+","\\mathbf","{","\\delta","}","where",":","math",":","`","\\mathbf","{","\\eta","}","`","is","the","set","of","endogenous","variables",",",":","math",":","`","\\mathbf","{","\\xi","}","`","is","the","set","of","exogeneous","variables",",",":","math",":","`","\\mathbf","{","y","}","`","and",":","math",":","`","\\mathbf","{","x","}","`","are","the","set","of","measurement","variables","for",":","math",":","`","\\mathbf","{","\\eta","}","`","and",":","math",":","`","\\mathbf","{","\\xi","}","`","respectively",".",":","math",":","`","\\mathbf","{","\\zeta","}","`",",",":","math",":","`","\\mathbf","{","\\epsilon","}","`",",","and",":","math",":","`","\\mathbf","{","\\delta","}","`","are","the","error","terms","for",":","math",":","`","\\mathbf","{","\\eta","}","`",",",":","math",":","`","\\mathbf","{","y","}","`",",","and",":","math",":","`","\\mathbf","{","x","}","`","respectively",".","Parameters","--","--","--","--","--","str_model",":","str","(","default",":","None",")","A","`","lavaan","`","style","multiline","set","of","regression","equation","representing","the","model",".","Refer","http",":","\/\/lavaan.ugent.be\/tutorial\/syntax1.html","for","details",".","If","None","requires","`","var_names","`","and","`","params","`","to","be","specified",".","var_names",":","dict","(","default",":","None",")","A","dict","with","the","keys",":","eta",",","xi",",","y",",","and","x",".","Each","keys","should","have","a","list","as","the","value","with","the","name","of","variables",".","params",":","dict","(","default",":","None",")","A","dict","of","LISREL","representation","non-zero","parameters",".","Must","contain","the","following","keys",":","B",",","gamma",",","wedge_y",",","wedge_x",",","phi",",","theta_e",",","theta_del",",","and","psi",".","If","None","`","str_model","`","must","be","specified",".","fixed_params",":","dict","(","default",":","None",")","A","dict","of","fixed","values","for","parameters",".","The","shape","of","the","parameters","should","be","same","as","params",".","If","None","all","the","parameters","are","learnable",".","Returns","--","--","--","-","pgmpy.models.SEM","instance",":","An","instance","of","the","object","with","initalized","values",".","Examples","--","--","--","--",">",">",">","from","pgmpy.models","import","SEMAlg","#","TODO",":","Finish","this","example"]
code: def from_lisrel(cls, var_names, params, fixed_masks=None):
      r"""
          Initializes a `SEM` instance using LISREL notation. The LISREL notation is defined as:
          ..math::
  
              \mathbf{\eta} = \mathbf{B \eta} + \mathbf{\Gamma \xi} + mathbf{\zeta} \\
              \mathbf{y} = \mathbf{\wedge_y \eta} + \mathbf{\epsilon} \\
              \mathbf{x} = \mathbf{\wedge_x \xi} + \mathbf{\delta}
  
          where :math:`\mathbf{\eta}` is the set of endogenous variables, :math:`\mathbf{\xi}`
          is the set of exogeneous variables, :math:`\mathbf{y}` and :math:`\mathbf{x}` are the
          set of measurement variables for :math:`\mathbf{\eta}` and :math:`\mathbf{\xi}`
          respectively. :math:`\mathbf{\zeta}`, :math:`\mathbf{\epsilon}`, and :math:`\mathbf{\delta}`
          are the error terms for :math:`\mathbf{\eta}`, :math:`\mathbf{y}`, and :math:`\mathbf{x}`
          respectively.
  
          Parameters
          ----------
          str_model: str (default: None)
              A `lavaan` style multiline set of regression equation representing the model.
              Refer http://lavaan.ugent.be/tutorial/syntax1.html for details.
  
              If None requires `var_names` and `params` to be specified.
  
          var_names: dict (default: None)
              A dict with the keys: eta, xi, y, and x. Each keys should have a list as the value
              with the name of variables.
  
          params: dict (default: None)
              A dict of LISREL representation non-zero parameters. Must contain the following
              keys: B, gamma, wedge_y, wedge_x, phi, theta_e, theta_del, and psi.
  
              If None `str_model` must be specified.
  
          fixed_params: dict (default: None)
              A dict of fixed values for parameters. The shape of the parameters should be same
              as params.
  
              If None all the parameters are learnable.
  
          Returns
          -------
          pgmpy.models.SEM instance: An instance of the object with initalized values.
  
          Examples
          --------
          >>> from pgmpy.models import SEMAlg
          # TODO: Finish this example
          """
      eta = (
          var_names["y"]
          + var_names["x"]
          + var_names["eta"]
          + var_names["xi"]
      )
      m, n, p, q = (
          len(var_names["y"]),
          len(var_names["x"]),
          len(var_names["eta"]),
          len(var_names["xi"]),
      )
  
      B = np.block(
          [
              [
                  np.zeros((m, m + n)),
                  params["wedge_y"],
                  np.zeros((m, q)),
              ],
              [np.zeros((n, m + n + p)), params["wedge_x"]],
              [np.zeros((p, m + n)), params["B"], params["gamma"]],
              [np.zeros((q, m + n + p + q))],
          ]
      )
      zeta = np.block(
          [
              [params["theta_e"], np.zeros((m, n + p + q))],
              [
                  np.zeros((n, m)),
                  params["theta_del"],
                  np.zeros((n, p + q)),
              ],
              [np.zeros((p, m + n)), params["psi"], np.zeros((p, q))],
              [np.zeros((q, m + n + p)), params["phi"]],
          ]
      )
  
      B = np.block(
          [
              [
                  np.zeros((m, m + n)),
                  fixed_params["wedge_y"],
                  np.zeros((m, q)),
              ],
              [np.zeros((n, m + n + p)), fixed_params["wedge_x"]],
              [
                  np.zeros((p, m + n)),
                  fixed_params["B"],
                  fixed_params["gamma"],
              ],
              [np.zeros((q, m + n + p + q))],
          ]
      )
      zeta = np.block(
          [
              [fixed_params["theta_e"], np.zeros((m, n + p + q))],
              [
                  np.zeros((n, m)),
                  fixed_params["theta_del"],
                  np.zeros((n, p + q)),
              ],
              [
                  np.zeros((p, m + n)),
                  fixed_params["psi"],
                  np.zeros((p, q)),
              ],
              [np.zeros((q, m + n + p)), fixed_params["phi"]],
          ]
      )
      observed = var_names["y"] + var_names["x"]
  
      return cls.from_RAM(
          variables=eta,
          B=B,
          zeta=zeta,
          observed=observed,
          fixed_values={"B": B, "zeta": zeta},
      )
  
imports: import itertools
  import networkx
  import numpy
  import pandas
  from networkx.algorithms.dag import descendants
  from pyparsing import OneOrMore, Optional, Suppress, Word, alphanums, nums
  from pgmpy.base import DAG
  from pgmpy.global_vars import logger
label_desc: Use image node_id 4 for calling the SEM obj's underlying member method code with example usage: obj.from_lisrel(cls, var_names, params, fixed_masks) and returns: cls