class_docstr: Base class of SEM estimators. All the estimators inherit this class.
class_docstr_tok: ["Base","class","of","SEM","estimators",".","All","the","estimators","inherit","this","class","."]
code: def __init__(self, model):
      if config.BACKEND == "numpy":
          raise ValueError(
              f"SEMEstimator requires torch backend. Currently it's numpy. Call pgmpy.config.set_backend('torch') to switch"
          )
  
      if isinstance(model, (SEMGraph, SEM)):
          self.model = model.to_lisrel()
      elif isinstance(model, SEMAlg):
          self.model = model
      else:
          raise ValueError(
              f"Model should be an instance of either SEMGraph or SEMAlg class. Got type: {type(model)}"
          )
  
      # Initialize trainable and fixed mask tensors
      self.B_mask = torch.tensor(
          self.model.B_mask,
          device=config.DEVICE,
          dtype=config.DTYPE,
          requires_grad=False,
      )
      self.zeta_mask = torch.tensor(
          self.model.zeta_mask,
          device=config.DEVICE,
          dtype=config.DTYPE,
          requires_grad=False,
      )
  
      self.B_fixed_mask = torch.tensor(
          self.model.B_fixed_mask,
          device=config.DEVICE,
          dtype=config.DTYPE,
          requires_grad=False,
      )
      self.zeta_fixed_mask = torch.tensor(
          self.model.zeta_fixed_mask,
          device=config.DEVICE,
          dtype=config.DTYPE,
          requires_grad=False,
      )
  
      self.wedge_y = torch.tensor(
          self.model.wedge_y,
          device=config.DEVICE,
          dtype=config.DTYPE,
          requires_grad=False,
      )
      self.B_eye = torch.eye(
          self.B_mask.shape[0],
          device=config.DEVICE,
          dtype=config.DTYPE,
          requires_grad=False,
      )
  
file_path: pgmpy/pgmpy/estimators/SEMEstimator.py
imports: import numpy
  import pandas
  import statsmodels.api
  import torch
  from pgmpy import config
  from pgmpy.models import SEM, SEMAlg, SEMGraph
  from pgmpy.utils import optimize, pinverse
label_desc: Use image node_id 1 to create a new SEMEstimator object from inherited base classes: object with example: obj = SEMEstimator(model)