docstr: Deals with all elimination order parameters given to _variable_elimination method
  and returns a list of variables that are to be eliminated
  
  Parameters
  ----------
  elimination_order: str or list
  
  Returns
  -------
  list: A list of variables names in the order they need to be eliminated.
docstr_tok: ["Deals","with","all","elimination","order","parameters","given","to","_variable_elimination","method","and","returns","a","list","of","variables","that","are","to","be","eliminated","Parameters","--","--","--","--","--","elimination_order",":","str","or","list","Returns","--","--","--","-","list",":","A","list","of","variables","names","in","the","order","they","need","to","be","eliminated","."]
code: def _get_elimination_order(
      self, variables, evidence, elimination_order, show_progress=True
  ):
      """
      Deals with all elimination order parameters given to _variable_elimination method
      and returns a list of variables that are to be eliminated
  
      Parameters
      ----------
      elimination_order: str or list
  
      Returns
      -------
      list: A list of variables names in the order they need to be eliminated.
      """
      to_eliminate = (
          set(self.variables)
          - set(variables)
          - set(evidence.keys() if evidence else [])
      )
  
      # Step 1: If elimination_order is a list, verify it's correct and return.
      # Step 1.1: Check that not of the `variables` and `evidence` is in the elimination_order.
      if hasattr(elimination_order, "__iter__") and (
          not isinstance(elimination_order, str)
      ):
          if any(
              var in elimination_order
              for var in set(variables).union(
                  set(evidence.keys() if evidence else [])
              )
          ):
              raise ValueError(
                  "Elimination order contains variables which are in"
                  " variables or evidence args"
              )
          # Step 1.2: Check if elimination_order has variables which are not in the model.
          elif any(
              var not in self.model.nodes() for var in elimination_order
          ):
              elimination_order = list(
                  filter(
                      lambda t: t in self.model.nodes(),
                      elimination_order,
                  )
              )
  
          # Step 1.3: Check if the elimination_order has all the variables that need to be eliminated.
          elif to_eliminate != set(elimination_order):
              raise ValueError(
                  f"Elimination order doesn't contain all the variables"
                  f"which need to be eliminated. The variables which need to"
                  f"be eliminated are {to_eliminate}"
              )
  
          return elimination_order
  
      # Step 2: If elimination order is None or a Markov model, return a random order.
      elif (elimination_order is None) or (
          not isinstance(self.model, BayesianNetwork)
      ):
          return to_eliminate
  
      # Step 3: If elimination order is a str, compute the order using the specified heuristic.
      elif isinstance(elimination_order, str) and isinstance(
          self.model, BayesianNetwork
      ):
          heuristic_dict = {
              "weightedminfill": WeightedMinFill,
              "minneighbors": MinNeighbors,
              "minweight": MinWeight,
              "minfill": MinFill,
          }
          elimination_order = heuristic_dict[elimination_order.lower()](
              self.model
          ).get_elimination_order(
              nodes=to_eliminate, show_progress=show_progress
          )
          return elimination_order
  
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 2 for calling the VariableElimination obj's underlying member method code with example usage: obj._get_elimination_order(variables, evidence, elimination_order, show_progress) and returns: elimination_order, to_eliminate, elimination_order