class_docstr: Remove useless statement like:
      - assignment to unused variables
      - remove alone pure statement
      - remove empty if
  
  >>> import gast as ast
  >>> from pythran import passmanager, backend
  >>> pm = passmanager.PassManager("test")
  >>> node = ast.parse("def foo(): a = [2, 3]; return 1")
  >>> _, node = pm.apply(DeadCodeElimination, node)
  >>> print(pm.dump(backend.Python, node))
  def foo():
      pass
      return 1
  >>> node = ast.parse("def foo(): 'a simple string'; return 1")
  >>> _, node = pm.apply(DeadCodeElimination, node)
  >>> print(pm.dump(backend.Python, node))
  def foo():
      pass
      return 1
  >>> node = ast.parse('''
  ... def bar(a):
  ...     return a
  ... def foo(a):
  ...    bar(a)
  ...    return 1''')
  >>> _, node = pm.apply(DeadCodeElimination, node)
  >>> print(pm.dump(backend.Python, node))
  def bar(a):
      return a
  def foo(a):
      pass
      return 1
class_docstr_tok: ["Remove","useless","statement","like",":","-","assignment","to","unused","variables","-","remove","alone","pure","statement","-","remove","empty","if",">",">",">","import","gast","as","ast",">",">",">","from","pythran","import","passmanager",",","backend",">",">",">","pm","=","passmanager.PassManager","(","``","test","''",")",">",">",">","node","=","ast.parse","(","``","def","foo","(",")",":","a","=","[","2",",","3","]",";","return","1","''",")",">",">",">","_",",","node","=","pm.apply","(","DeadCodeElimination",",","node",")",">",">",">","print","(","pm.dump","(","backend.Python",",","node",")",")","def","foo","(",")",":","pass","return","1",">",">",">","node","=","ast.parse","(","``","def","foo","(",")",":","'","a","simple","string","'",";","return","1","''",")",">",">",">","_",",","node","=","pm.apply","(","DeadCodeElimination",",","node",")",">",">",">","print","(","pm.dump","(","backend.Python",",","node",")",")","def","foo","(",")",":","pass","return","1",">",">",">","node","=","ast.parse","(","``","'","...","def","bar","(","a",")",":","...","return","a","...","def","foo","(","a",")",":","...","bar","(","a",")","...","return","1","''","'",")",">",">",">","_",",","node","=","pm.apply","(","DeadCodeElimination",",","node",")",">",">",">","print","(","pm.dump","(","backend.Python",",","node",")",")","def","bar","(","a",")",":","return","a","def","foo","(","a",")",":","pass","return","1"]
code: def visit_If(self, node):
      self.generic_visit(node)
  
      try:
          if ast.literal_eval(node.test):
              if not metadata.get(node, OMPDirective):
                  self.update = True
                  return node.body
          else:
              if not metadata.get(node, OMPDirective):
                  self.update = True
                  return node.orelse
      except ValueError:
          # not a constant expression
          pass
  
      have_body = any(not isinstance(x, ast.Pass) for x in node.body)
      have_else = any(not isinstance(x, ast.Pass) for x in node.orelse)
      # If the "body" is empty but "else content" is useful, switch branches
      # and remove else content
      if not have_body and have_else:
          test = ast.UnaryOp(op=ast.Not(), operand=node.test)
          self.update = True
          return ast.If(test=test, body=node.orelse, orelse=list())
      # if neither "if" and "else" are useful, keep test if it is not pure
      elif not have_body:
          self.update = True
          if node.test in self.pure_expressions:
              return ast.Pass()
          else:
              node = ast.Expr(value=node.test)
              self.generic_visit(node)
      return node
  
file_path: catboost/contrib/python/pythran/pythran/optimizations/dead_code_elimination.py
imports: from pythran.analyses import PureExpressions, DefUseChains, Ancestors
  from pythran.openmp import OMPDirective
  from pythran.passmanager import Transformation
  import pythran.metadata
  import gast
label_desc: Use image node_id 7 for calling the DeadCodeElimination obj's underlying member method code with example usage: obj.visit_If(node) and returns: node, ast, node, node, ast