class_docstr: Defines the conditional probability distribution table (CPD table)
  
  Parameters
  ----------
  variable: int, string (any hashable python object)
      The variable whose CPD is defined.
  
  variable_card: integer
      Cardinality/no. of states of `variable`
  
  values: 2D array, 2D list or 2D tuple
      Values for the CPD table. Please refer the example for the
      exact format needed.
  
  evidence: array-like
      List of variables in evidences(if any) w.r.t. which CPD is defined.
  
  evidence_card: array-like
      cardinality/no. of states of variables in `evidence`(if any)
  
  Examples
  --------
  For a distribution of P(grade|diff, intel)
  
  +---------+-------------------------+------------------------+
  |diff:    |          easy           |         hard           |
  +---------+------+--------+---------+------+--------+--------+
  |aptitude:| low  | medium |  high   | low  | medium |  high  |
  +---------+------+--------+---------+------+--------+--------+
  |gradeA   | 0.1  | 0.1    |   0.1   |  0.1 |  0.1   |   0.1  |
  +---------+------+--------+---------+------+--------+--------+
  |gradeB   | 0.1  | 0.1    |   0.1   |  0.1 |  0.1   |   0.1  |
  +---------+------+--------+---------+------+--------+--------+
  |gradeC   | 0.8  | 0.8    |   0.8   |  0.8 |  0.8   |   0.8  |
  +---------+------+--------+---------+------+--------+--------+
  
  values should be
  [[0.1,0.1,0.1,0.1,0.1,0.1],
  [0.1,0.1,0.1,0.1,0.1,0.1],
  [0.8,0.8,0.8,0.8,0.8,0.8]]
  
  >>> cpd = TabularCPD('grade',3,[[0.1,0.1,0.1,0.1,0.1,0.1],
  ...                             [0.1,0.1,0.1,0.1,0.1,0.1],
  ...                             [0.8,0.8,0.8,0.8,0.8,0.8]],
  ...                             evidence=['diff', 'intel'], evidence_card=[2,3])
  >>> print(cpd)
  +---------+---------+---------+---------+---------+---------+---------+
  | diff    | diff_0  | diff_0  | diff_0  | diff_1  | diff_1  | diff_1  |
  +---------+---------+---------+---------+---------+---------+---------+
  | intel   | intel_0 | intel_1 | intel_2 | intel_0 | intel_1 | intel_2 |
  +---------+---------+---------+---------+---------+---------+---------+
  | grade_0 | 0.1     | 0.1     | 0.1     | 0.1     | 0.1     | 0.1     |
  +---------+---------+---------+---------+---------+---------+---------+
  | grade_1 | 0.1     | 0.1     | 0.1     | 0.1     | 0.1     | 0.1     |
  +---------+---------+---------+---------+---------+---------+---------+
  | grade_2 | 0.8     | 0.8     | 0.8     | 0.8     | 0.8     | 0.8     |
  +---------+---------+---------+---------+---------+---------+---------+
  >>> cpd.values
  array([[[ 0.1,  0.1,  0.1],
          [ 0.1,  0.1,  0.1]],
         [[ 0.1,  0.1,  0.1],
          [ 0.1,  0.1,  0.1]],
         [[ 0.8,  0.8,  0.8],
          [ 0.8,  0.8,  0.8]]])
  >>> cpd.variables
  ['grade', 'diff', 'intel']
  >>> cpd.cardinality
  array([3, 2, 3])
  >>> cpd.variable
  'grade'
  >>> cpd.variable_card
  3
class_docstr_tok: ["Defines","the","conditional","probability","distribution","table","(","CPD","table",")","Parameters","--","--","--","--","--","variable",":","int",",","string","(","any","hashable","python","object",")","The","variable","whose","CPD","is","defined",".","variable_card",":","integer","Cardinality\/no",".","of","states","of","`","variable","`","values",":","2D","array",",","2D","list","or","2D","tuple","Values","for","the","CPD","table",".","Please","refer","the","example","for","the","exact","format","needed",".","evidence",":","array-like","List","of","variables","in","evidences","(","if","any",")","w.r.t",".","which","CPD","is","defined",".","evidence_card",":","array-like","cardinality\/no",".","of","states","of","variables","in","`","evidence","`","(","if","any",")","Examples","--","--","--","--","For","a","distribution","of","P","(","grade|diff",",","intel",")","+","--","--","--","--","-+","--","--","--","--","--","--","--","--","--","--","--","--","-+","--","--","--","--","--","--","--","--","--","--","--","--","+","|diff",":","|","easy","|","hard","|","+","--","--","--","--","-+","--","--","--","+","--","--","--","--","+","--","--","--","--","-+","--","--","--","+","--","--","--","--","+","--","--","--","--","+","|aptitude",":","|","low","|","medium","|","high","|","low","|","medium","|","high","|","+","--","--","--","--","-+","--","--","--","+","--","--","--","--","+","--","--","--","--","-+","--","--","--","+","--","--","--","--","+","--","--","--","--","+","|gradeA","|","0.1","|","0.1","|","0.1","|","0.1","|","0.1","|","0.1","|","+","--","--","--","--","-+","--","--","--","+","--","--","--","--","+","--","--","--","--","-+","--","--","--","+","--","--","--","--","+","--","--","--","--","+","|gradeB","|","0.1","|","0.1","|","0.1","|","0.1","|","0.1","|","0.1","|","+","--","--","--","--","-+","--","--","--","+","--","--","--","--","+","--","--","--","--","-+","--","--","--","+","--","--","--","--","+","--","--","--","--","+","|gradeC","|","0.8","|","0.8","|","0.8","|","0.8","|","0.8","|","0.8","|","+","--","--","--","--","-+","--","--","--","+","--","--","--","--","+","--","--","--","--","-+","--","--","--","+","--","--","--","--","+","--","--","--","--","+","values","should","be","[","[","0.1,0.1,0.1,0.1,0.1,0.1","]",",","[","0.1,0.1,0.1,0.1,0.1,0.1","]",",","[","0.8,0.8,0.8,0.8,0.8,0.8","]","]",">",">",">","cpd","=","TabularCPD","(","'grade',3",",","[","[","0.1,0.1,0.1,0.1,0.1,0.1","]",",","...","[","0.1,0.1,0.1,0.1,0.1,0.1","]",",","...","[","0.8,0.8,0.8,0.8,0.8,0.8","]","]",",","...","evidence=","[","'diff","'",",","'intel","'","]",",","evidence_card=","[","2,3","]",")",">",">",">","print","(","cpd",")","+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","|","diff","|","diff_0","|","diff_0","|","diff_0","|","diff_1","|","diff_1","|","diff_1","|","+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","|","intel","|","intel_0","|","intel_1","|","intel_2","|","intel_0","|","intel_1","|","intel_2","|","+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","|","grade_0","|","0.1","|","0.1","|","0.1","|","0.1","|","0.1","|","0.1","|","+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","|","grade_1","|","0.1","|","0.1","|","0.1","|","0.1","|","0.1","|","0.1","|","+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","|","grade_2","|","0.8","|","0.8","|","0.8","|","0.8","|","0.8","|","0.8","|","+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+","--","--","--","--","-+",">",">",">","cpd.values","array","(","[","[","[","0.1",",","0.1",",","0.1","]",",","[","0.1",",","0.1",",","0.1","]","]",",","[","[","0.1",",","0.1",",","0.1","]",",","[","0.1",",","0.1",",","0.1","]","]",",","[","[","0.8",",","0.8",",","0.8","]",",","[","0.8",",","0.8",",","0.8","]","]","]",")",">",">",">","cpd.variables","[","'grade","'",",","'diff","'",",","'intel","'","]",">",">",">","cpd.cardinality","array","(","[","3",",","2",",","3","]",")",">",">",">","cpd.variable","'grade'",">",">",">","cpd.variable_card","3"]
docstr: Reduces the cpd table to the context of given variable values. Reduce fixes the
  state of given variable to specified value. The reduced variables will no longer
  appear in the CPD.
  
  Parameters
  ----------
  values: list, array-like
      A list of tuples of the form (variable_name, variable_state).
  
  inplace: boolean
      If inplace=True it will modify the factor itself, else would return
      a new factor.
  
  Examples
  --------
  >>> from pgmpy.factors.discrete import TabularCPD
  >>> cpd_table = TabularCPD('grade', 2,
  ...                        [[0.7, 0.6, 0.6, 0.2],[0.3, 0.4, 0.4, 0.8]],
  ...                        ['intel', 'diff'], [2, 2])
  >>> cpd_table.reduce([('diff', 0)])
  >>> cpd_table.get_values()
  array([[ 0.7,  0.6],
         [ 0.3,  0.4]])
docstr_tok: ["Reduces","the","cpd","table","to","the","context","of","given","variable","values",".","Reduce","fixes","the","state","of","given","variable","to","specified","value",".","The","reduced","variables","will","no","longer","appear","in","the","CPD",".","Parameters","--","--","--","--","--","values",":","list",",","array-like","A","list","of","tuples","of","the","form","(","variable_name",",","variable_state",")",".","inplace",":","boolean","If","inplace=True","it","will","modify","the","factor","itself",",","else","would","return","a","new","factor",".","Examples","--","--","--","--",">",">",">","from","pgmpy.factors.discrete","import","TabularCPD",">",">",">","cpd_table","=","TabularCPD","(","'grade","'",",","2",",","...","[","[","0.7",",","0.6",",","0.6",",","0.2","]",",","[","0.3",",","0.4",",","0.4",",","0.8","]","]",",","...","[","'intel","'",",","'diff","'","]",",","[","2",",","2","]",")",">",">",">","cpd_table.reduce","(","[","(","'diff","'",",","0",")","]",")",">",">",">","cpd_table.get_values","(",")","array","(","[","[","0.7",",","0.6","]",",","[","0.3",",","0.4","]","]",")"]
code: def reduce(self, values, inplace=True, show_warnings=True):
      """
      Reduces the cpd table to the context of given variable values. Reduce fixes the
      state of given variable to specified value. The reduced variables will no longer
      appear in the CPD.
  
      Parameters
      ----------
      values: list, array-like
          A list of tuples of the form (variable_name, variable_state).
  
      inplace: boolean
          If inplace=True it will modify the factor itself, else would return
          a new factor.
  
      Examples
      --------
      >>> from pgmpy.factors.discrete import TabularCPD
      >>> cpd_table = TabularCPD('grade', 2,
      ...                        [[0.7, 0.6, 0.6, 0.2],[0.3, 0.4, 0.4, 0.8]],
      ...                        ['intel', 'diff'], [2, 2])
      >>> cpd_table.reduce([('diff', 0)])
      >>> cpd_table.get_values()
      array([[ 0.7,  0.6],
             [ 0.3,  0.4]])
      """
      if self.variable in (value[0] for value in values):
          raise ValueError(
              "Reduce not allowed on the variable on which CPD is defined"
          )
  
      tabular_cpd = self if inplace else self.copy()
  
      super(TabularCPD, tabular_cpd).reduce(
          values, show_warnings=show_warnings
      )
      tabular_cpd.normalize()
  
      if not inplace:
          return tabular_cpd
  
imports: import csv
  import numbers
  from itertools import chain, product
  from shutil import get_terminal_size
  from warnings import warn
  import numpy
  import torch
  from pgmpy import config
  from pgmpy.extern import tabulate
  from pgmpy.factors.discrete import DiscreteFactor
  from pgmpy.utils import compat_fns
label_desc: Use image node_id 12 for calling the TabularCPD obj's underlying member method code with example usage: obj.reduce(values, inplace, show_warnings) and returns: tabular_cpd