def _exponents(expr, x):
 def _exponents_(expr, x, res):
  if (expr == x):
   res.update([1])
   return
  if (expr.is_Pow and (expr.base == x)):
   res.update([expr.exp])
   return
  for arg in expr.args:
   _exponents_(arg, x, res)
 res = set()
 _exponents_(expr, x, res)
 return res

def _exponents ( expr , x ) : def _exponents_ ( expr , x , res ) : if ( expr == x ) : res . update ( [ 1 ] ) return if ( expr . is_Pow and ( expr . base == x ) ) : res . update ( [ expr . exp ] ) return for arg in expr . args : _exponents_ ( arg , x , res ) res = set ( ) _exponents_ ( expr , x , res ) return res
find the exponents of x in expr .