class_docstr: Initialize an instance of UAI reader class
  
  Parameters
  ----------
  path : file or str
      Path of the file containing UAI information.
  
  string : str
      String containing UAI information.
  
  Examples
  --------
  >>> from pgmpy.readwrite import UAIReader
  >>> reader = UAIReader('TestUai.uai')
  >>> model = reader.get_model()
  
  Reference
  ---------
  [1] https://uaicompetition.github.io/uci-2022/file-formats/model-format/
  [2] https://forgemia.inra.fr/thomas.schiex/toulbar2/-/blob/master/doc/UAI08Format.txt
docstr: Returns an instance of Bayesian Model or Markov Model.
  Variables are in the pattern var_0, var_1, var_2 where var_0 is
  0th index variable, var_1 is 1st index variable.
  
  Return
  ------
  model: an instance of Bayesian or Markov Model.
  
  Examples
  --------
  >>> from pgmpy.readwrite import UAIReader
  >>> reader = UAIReader('TestUAI.uai')
  >>> reader.get_model()
docstr_tok: ["Returns","an","instance","of","Bayesian","Model","or","Markov","Model",".","Variables","are","in","the","pattern","var_0",",","var_1",",","var_2","where","var_0","is","0th","index","variable",",","var_1","is","1st","index","variable",".","Return","--","--","--","model",":","an","instance","of","Bayesian","or","Markov","Model",".","Examples","--","--","--","--",">",">",">","from","pgmpy.readwrite","import","UAIReader",">",">",">","reader","=","UAIReader","(","'TestUAI.uai","'",")",">",">",">","reader.get_model","(",")"]
code: def get_model(self):
      """
      Returns an instance of Bayesian Model or Markov Model.
      Variables are in the pattern var_0, var_1, var_2 where var_0 is
      0th index variable, var_1 is 1st index variable.
  
      Return
      ------
      model: an instance of Bayesian or Markov Model.
  
      Examples
      --------
      >>> from pgmpy.readwrite import UAIReader
      >>> reader = UAIReader('TestUAI.uai')
      >>> reader.get_model()
      """
      if self.network_type == "BAYES":
          model = BayesianNetwork()
          model.add_nodes_from(self.variables)
          model.add_edges_from(self.edges)
  
          tabular_cpds = []
          for child_var, values in self.tables:
              states = int(self.domain[child_var])
              values = np.fromiter(values, dtype=float)
              values = values.reshape(states, values.size // states)
              parents = list(model.predecessors(child_var))
              if len(parents) == 0:
                  tabular_cpds.append(
                      TabularCPD(child_var, states, values)
                  )
              else:
                  tabular_cpds.append(
                      TabularCPD(
                          child_var,
                          states,
                          values,
                          evidence=parents,
                          evidence_card=[
                              int(self.domain[var]) for var in parents
                          ],
                      )
                  )
  
          model.add_cpds(*tabular_cpds)
          return model
  
      elif self.network_type == "MARKOV":
          model = MarkovNetwork(self.edges)
  
          factors = []
          for table in self.tables:
              variables = table[0]
              cardinality = [int(self.domain[var]) for var in variables]
              value = list(map(float, table[1]))
              factor = DiscreteFactor(
                  variables=variables,
                  cardinality=cardinality,
                  values=value,
              )
              factors.append(factor)
  
          model.add_factors(*factors)
          return model
  
imports: from itertools import combinations
  import numpy
  from pyparsing import Combine, Literal, Optional, Regex, Word, alphas, nums
  from pgmpy.factors.discrete import DiscreteFactor, TabularCPD
  from pgmpy.models import BayesianNetwork, MarkovNetwork
  from pgmpy.utils import compat_fns
label_desc: Use image node_id 8 for calling the UAIReader obj's underlying member method code with example usage: obj.get_model() and returns: model, model