code: def remove_trivial(root):
      """
      Remove redundant statements.
  
      The statement `a = 1` will be removed::
  
          a = 1
          a = 2
  
      The statement `a = 1` will not be removed because `b` depends on it::
  
          a = 1
          b = a + 2
          a = 2
  
      :param root: ast node
      """
  
      gen = GatherAssignments()
      gen.visit(root)
  
      to_remove = []
  
      for symbol, assignments in gen.assign_id_map.items():
          if len(assignments) < 2:
              continue
  
          for j in range(len(assignments) - 1):
              i1 = root.body.index(assignments[j].root)
              i2 = root.body.index(assignments[j + 1].root)
  
              body = root.body[i1 + 1 : i2]
              grapher = GraphGen()
              for stmnt in body:
                  grapher.visit(stmnt)
  
              if symbol not in grapher.used:
                  to_remove.extend(assignments[j].assignments)
  
      Pass = lambda node: _ast.Pass(
          lineno=node.lineno, col_offset=node.col_offset
      )
  
      for old in to_remove:
          replace_nodes(root, old, Pass(old))
  
file_path: turicreate/src/python/turicreate/meta/asttools/mutators/remove_trivial.py
imports: from __future__ import print_function
  from __future__ import division
  from __future__ import absolute_import
  import _ast
  import ast
  from ...asttools.visitors.graph_visitor import GraphGen
  from ...asttools import Visitor, dont_visit, visit_children
  from ...asttools.mutators.replace_mutator import replace_nodes
  from ...asttools.visitors.symbol_visitor import get_symbols
  from ...asttools.visitors.cond_symbol_visitor import conditional_lhs
label_desc: Use image node_id 2 for calling a global function with example usage: remove_trivial(root) without return types