docstr: Computes the max-marginal over the variables given the evidence.
  
  Parameters
  ----------
  variables: list
      list of variables over which we want to compute the max-marginal.
  
  evidence: dict
      a dict key, value pair as {var: state_of_var_observed}
      None if no evidence
  
  elimination_order: list
      order of variable eliminations (if nothing is provided) order is
      computed automatically
  
  Examples
  --------
  >>> import numpy as np
  >>> import pandas as pd
  >>> from pgmpy.models import BayesianNetwork
  >>> from pgmpy.inference import VariableElimination
  >>> values = pd.DataFrame(np.random.randint(low=0, high=2, size=(1000, 5)),
  ...                       columns=['A', 'B', 'C', 'D', 'E'])
  >>> model = BayesianNetwork([('A', 'B'), ('C', 'B'), ('C', 'D'), ('B', 'E')])
  >>> model.fit(values)
  >>> inference = VariableElimination(model)
  >>> phi_query = inference.max_marginal(['A', 'B'])
docstr_tok: ["Computes","the","max-marginal","over","the","variables","given","the","evidence",".","Parameters","--","--","--","--","--","variables",":","list","list","of","variables","over","which","we","want","to","compute","the","max-marginal",".","evidence",":","dict","a","dict","key",",","value","pair","as","{","var",":","state_of_var_observed","}","None","if","no","evidence","elimination_order",":","list","order","of","variable","eliminations","(","if","nothing","is","provided",")","order","is","computed","automatically","Examples","--","--","--","--",">",">",">","import","numpy","as","np",">",">",">","import","pandas","as","pd",">",">",">","from","pgmpy.models","import","BayesianNetwork",">",">",">","from","pgmpy.inference","import","VariableElimination",">",">",">","values","=","pd.DataFrame","(","np.random.randint","(","low=0",",","high=2",",","size=","(","1000",",","5",")",")",",","...","columns=","[","'","A","'",",","'","B","'",",","'","C","'",",","'D","'",",","'","E","'","]",")",">",">",">","model","=","BayesianNetwork","(","[","(","'","A","'",",","'","B","'",")",",","(","'","C","'",",","'","B","'",")",",","(","'","C","'",",","'D","'",")",",","(","'","B","'",",","'","E","'",")","]",")",">",">",">","model.fit","(","values",")",">",">",">","inference","=","VariableElimination","(","model",")",">",">",">","phi_query","=","inference.max_marginal","(","[","'","A","'",",","'","B","'","]",")"]
code: def max_marginal(
      self,
      variables=None,
      evidence=None,
      elimination_order="MinFill",
      show_progress=True,
  ):
      """
      Computes the max-marginal over the variables given the evidence.
  
      Parameters
      ----------
      variables: list
          list of variables over which we want to compute the max-marginal.
  
      evidence: dict
          a dict key, value pair as {var: state_of_var_observed}
          None if no evidence
  
      elimination_order: list
          order of variable eliminations (if nothing is provided) order is
          computed automatically
  
      Examples
      --------
      >>> import numpy as np
      >>> import pandas as pd
      >>> from pgmpy.models import BayesianNetwork
      >>> from pgmpy.inference import VariableElimination
      >>> values = pd.DataFrame(np.random.randint(low=0, high=2, size=(1000, 5)),
      ...                       columns=['A', 'B', 'C', 'D', 'E'])
      >>> model = BayesianNetwork([('A', 'B'), ('C', 'B'), ('C', 'D'), ('B', 'E')])
      >>> model.fit(values)
      >>> inference = VariableElimination(model)
      >>> phi_query = inference.max_marginal(['A', 'B'])
      """
      if not variables:
          variables = []
  
      common_vars = set(
          evidence if evidence is not None else []
      ).intersection(set(variables if variables is not None else []))
      if common_vars:
          raise ValueError(
              f"Can't have the same variables in both `variables` and `evidence`. Found in both: {common_vars}"
          )
  
      if isinstance(self.model, BayesianNetwork):
          model_reduced, evidence = self._prune_bayesian_model(
              variables, evidence
          )
      else:
          model_reduced = self.model
  
      reduced_ve = VariableElimination(model_reduced)
      reduced_ve._initialize_structures()
  
      final_distribution = reduced_ve._variable_elimination(
          variables=variables,
          operation="maximize",
          evidence=evidence,
          elimination_order=elimination_order,
          show_progress=show_progress,
      )
  
      return compat_fns.max(final_distribution.values)
  
imports: import copy
  import itertools
  import networkx
  import numpy
  from opt_einsum import contract
  from tqdm.auto import tqdm
  from pgmpy import config
  from pgmpy.factors import factor_product
  from pgmpy.factors.discrete import DiscreteFactor
  from pgmpy.inference import Inference
  from pgmpy.inference.EliminationOrder import MinFill, MinNeighbors, MinWeight, WeightedMinFill
  from pgmpy.models import BayesianNetwork, DynamicBayesianNetwork, JunctionTree, MarkovNetwork
  from pgmpy.utils import compat_fns
label_desc: Use image node_id 5 for calling the VariableElimination obj's underlying member method code with example usage: obj.max_marginal(variables, evidence, elimination_order, show_progress) and returns: compat_fns