class_docstr: Initialize a `DiscreteFactor` class.
  
  Defined above, we have the following mapping from variable
  assignments to the index of the row vector in the value field:
  +-----+-----+-----+-------------------+
  |  x1 |  x2 |  x3 |    phi(x1, x2, x3)|
  +-----+-----+-----+-------------------+
  | x1_0| x2_0| x3_0|     phi.value(0)  |
  +-----+-----+-----+-------------------+
  | x1_0| x2_0| x3_1|     phi.value(1)  |
  +-----+-----+-----+-------------------+
  | x1_0| x2_1| x3_0|     phi.value(2)  |
  +-----+-----+-----+-------------------+
  | x1_0| x2_1| x3_1|     phi.value(3)  |
  +-----+-----+-----+-------------------+
  | x1_1| x2_0| x3_0|     phi.value(4)  |
  +-----+-----+-----+-------------------+
  | x1_1| x2_0| x3_1|     phi.value(5)  |
  +-----+-----+-----+-------------------+
  | x1_1| x2_1| x3_0|     phi.value(6)  |
  +-----+-----+-----+-------------------+
  | x1_1| x2_1| x3_1|     phi.value(7)  |
  +-----+-----+-----+-------------------+
  
  Parameters
  ----------
  variables: list, array-like
      List of variables on which the factor is to be defined i.e. scope of the factor.
  
  cardinality: list, array_like
      List of cardinalities/no.of states of each variable. `cardinality`
      array must have a value corresponding to each variable in
      `variables`.
  
  values: list, array_like
      List of values of factor.
      A DiscreteFactor's values are stored in a row vector in the value
      using an ordering such that the left-most variables as defined in
      `variables` cycle through their values the fastest. Please refer
      to examples for usage examples.
  
  Examples
  --------
  >>> import numpy as np
  >>> from pgmpy.factors.discrete import DiscreteFactor
  >>> phi = DiscreteFactor(['x1', 'x2', 'x3'], [2, 2, 2], np.ones(8))
  >>> phi
  <DiscreteFactor representing phi(x1:2, x2:2, x3:2) at 0x7f8188fcaa90>
  >>> print(phi)
  +------+------+------+-----------------+
  | x1   | x2   | x3   |   phi(x1,x2,x3) |
  |------+------+------+-----------------|
  | x1_0 | x2_0 | x3_0 |          1.0000 |
  | x1_0 | x2_0 | x3_1 |          1.0000 |
  | x1_0 | x2_1 | x3_0 |          1.0000 |
  | x1_0 | x2_1 | x3_1 |          1.0000 |
  | x1_1 | x2_0 | x3_0 |          1.0000 |
  | x1_1 | x2_0 | x3_1 |          1.0000 |
  | x1_1 | x2_1 | x3_0 |          1.0000 |
  | x1_1 | x2_1 | x3_1 |          1.0000 |
  +------+------+------+-----------------+
class_docstr_tok: ["Initialize","a","`","DiscreteFactor","`","class",".","Defined","above",",","we","have","the","following","mapping","from","variable","assignments","to","the","index","of","the","row","vector","in","the","value","field",":","+","--","--","-+","--","--","-+","--","--","-+","--","--","--","--","--","--","--","--","--","-+","|","x1","|","x2","|","x3","|","phi","(","x1",",","x2",",","x3",")","|","+","--","--","-+","--","--","-+","--","--","-+","--","--","--","--","--","--","--","--","--","-+","|","x1_0|","x2_0|","x3_0|","phi.value","(","0",")","|","+","--","--","-+","--","--","-+","--","--","-+","--","--","--","--","--","--","--","--","--","-+","|","x1_0|","x2_0|","x3_1|","phi.value","(","1",")","|","+","--","--","-+","--","--","-+","--","--","-+","--","--","--","--","--","--","--","--","--","-+","|","x1_0|","x2_1|","x3_0|","phi.value","(","2",")","|","+","--","--","-+","--","--","-+","--","--","-+","--","--","--","--","--","--","--","--","--","-+","|","x1_0|","x2_1|","x3_1|","phi.value","(","3",")","|","+","--","--","-+","--","--","-+","--","--","-+","--","--","--","--","--","--","--","--","--","-+","|","x1_1|","x2_0|","x3_0|","phi.value","(","4",")","|","+","--","--","-+","--","--","-+","--","--","-+","--","--","--","--","--","--","--","--","--","-+","|","x1_1|","x2_0|","x3_1|","phi.value","(","5",")","|","+","--","--","-+","--","--","-+","--","--","-+","--","--","--","--","--","--","--","--","--","-+","|","x1_1|","x2_1|","x3_0|","phi.value","(","6",")","|","+","--","--","-+","--","--","-+","--","--","-+","--","--","--","--","--","--","--","--","--","-+","|","x1_1|","x2_1|","x3_1|","phi.value","(","7",")","|","+","--","--","-+","--","--","-+","--","--","-+","--","--","--","--","--","--","--","--","--","-+","Parameters","--","--","--","--","--","variables",":","list",",","array-like","List","of","variables","on","which","the","factor","is","to","be","defined","i.e",".","scope","of","the","factor",".","cardinality",":","list",",","array_like","List","of","cardinalities\/no.of","states","of","each","variable",".","`","cardinality","`","array","must","have","a","value","corresponding","to","each","variable","in","`","variables","`",".","values",":","list",",","array_like","List","of","values","of","factor",".","A","DiscreteFactor","'s","values","are","stored","in","a","row","vector","in","the","value","using","an","ordering","such","that","the","left-most","variables","as","defined","in","`","variables","`","cycle","through","their","values","the","fastest",".","Please","refer","to","examples","for","usage","examples",".","Examples","--","--","--","--",">",">",">","import","numpy","as","np",">",">",">","from","pgmpy.factors.discrete","import","DiscreteFactor",">",">",">","phi","=","DiscreteFactor","(","[","'x1","'",",","'x2","'",",","'x3","'","]",",","[","2",",","2",",","2","]",",","np.ones","(","8",")",")",">",">",">","phi","<","DiscreteFactor","representing","phi","(","x1:2",",","x2:2",",","x3:2",")","at","0x7f8188fcaa90",">",">",">",">","print","(","phi",")","+","--","--","--","+","--","--","--","+","--","--","--","+","--","--","--","--","--","--","--","--","-+","|","x1","|","x2","|","x3","|","phi","(","x1",",","x2",",","x3",")","|","|","--","--","--","+","--","--","--","+","--","--","--","+","--","--","--","--","--","--","--","--","-|","|","x1_0","|","x2_0","|","x3_0","|","1.0000","|","|","x1_0","|","x2_0","|","x3_1","|","1.0000","|","|","x1_0","|","x2_1","|","x3_0","|","1.0000","|","|","x1_0","|","x2_1","|","x3_1","|","1.0000","|","|","x1_1","|","x2_0","|","x3_0","|","1.0000","|","|","x1_1","|","x2_0","|","x3_1","|","1.0000","|","|","x1_1","|","x2_1","|","x3_0","|","1.0000","|","|","x1_1","|","x2_1","|","x3_1","|","1.0000","|","+","--","--","--","+","--","--","--","+","--","--","--","+","--","--","--","--","--","--","--","--","-+"]
docstr: Returns the value of the given variable states. Assumes that the arguments
  specified are state names, and falls back to considering it as state no if
  can't find the state name.
  
  Parameters
  ----------
  kwargs: named arguments of the form variable=state_name
      Spcifies the state of each of the variable for which to get
      the value.
  
  Returns
  -------
  value of kwargs: float
      The value of specified states.
  
  Examples
  --------
  >>> from pgmpy.utils import get_example_model
  >>> model = get_example_model("asia")
  >>> phi = model.get_cpds("either").to_factor()
  >>> phi.get_value(lung="yes", tub="no", either="yes")
  1.0
docstr_tok: ["Returns","the","value","of","the","given","variable","states",".","Assumes","that","the","arguments","specified","are","state","names",",","and","falls","back","to","considering","it","as","state","no","if","ca","n't","find","the","state","name",".","Parameters","--","--","--","--","--","kwargs",":","named","arguments","of","the","form","variable=state_name","Spcifies","the","state","of","each","of","the","variable","for","which","to","get","the","value",".","Returns","--","--","--","-","value","of","kwargs",":","float","The","value","of","specified","states",".","Examples","--","--","--","--",">",">",">","from","pgmpy.utils","import","get_example_model",">",">",">","model","=","get_example_model","(","``","asia","''",")",">",">",">","phi","=","model.get_cpds","(","``","either","''",")",".to_factor","(",")",">",">",">","phi.get_value","(","lung=","''","yes","''",",","tub=","''","no","''",",","either=","''","yes","''",")","1.0"]
code: def get_value(self, **kwargs):
      """
      Returns the value of the given variable states. Assumes that the arguments
      specified are state names, and falls back to considering it as state no if
      can't find the state name.
  
      Parameters
      ----------
      kwargs: named arguments of the form variable=state_name
          Spcifies the state of each of the variable for which to get
          the value.
  
      Returns
      -------
      value of kwargs: float
          The value of specified states.
  
      Examples
      --------
      >>> from pgmpy.utils import get_example_model
      >>> model = get_example_model("asia")
      >>> phi = model.get_cpds("either").to_factor()
      >>> phi.get_value(lung="yes", tub="no", either="yes")
      1.0
      """
      for variable in kwargs.keys():
          if variable not in self.variables:
              raise ValueError(
                  f"Factor doesn't have the variable: {variable}"
              )
  
      index = []
      for var in self.variables:
          if var not in kwargs.keys():
              raise ValueError(
                  f"Variable: {var} not found in arguments"
              )
          else:
              try:
                  index.append(self.name_to_no[var][kwargs[var]])
              except KeyError:
                  logger.info(
                      f"Using {var} state as number instead of name."
                  )
                  index.append(kwargs[var])
      return self.values[tuple(index)]
  
imports: from collections import namedtuple
  from itertools import product
  import numpy
  import pandas
  import torch
  from pgmpy import config
  from pgmpy.extern import tabulate
  from pgmpy.factors.base import BaseFactor
  from pgmpy.global_vars import logger
  from pgmpy.utils import StateNameMixin, compat_fns
label_desc: Use image node_id 4 for calling the DiscreteFactor obj's underlying member method code with example usage: obj.get_value() and returns: self