code: def rm_id(isid, new=new):
      """Create a rule to remove identities.
  
      isid - fn :: x -> Bool  --- whether or not this element is an identity.
  
      Examples
      ========
  
      >>> from sympy.strategies import rm_id
      >>> from sympy import Basic, S
      >>> remove_zeros = rm_id(lambda x: x==0)
      >>> remove_zeros(Basic(S(1), S(0), S(2)))
      Basic(1, 2)
      >>> remove_zeros(Basic(S(0), S(0))) # If only identites then we keep one
      Basic(0)
  
      See Also:
          unpack
      """
  
      def ident_remove(expr):
          """Remove identities"""
          ids = list(map(isid, expr.args))
          if sum(ids) == 0:  # No identities. Common case
              return expr
          elif sum(ids) != len(
              ids
          ):  # there is at least one non-identity
              return new(
                  expr.__class__,
                  *[arg for arg, x in zip(expr.args, ids) if not x],
              )
          else:
              return new(expr.__class__, expr.args[0])
  
      return ident_remove
  
file_path: sympy/sympy/strategies/rl.py
imports: from sympy.utilities.iterables import sift
  from .util import new
label_desc: Use image node_id 1 for calling a global function with example usage: rm_id(isid, new) and returns: ident_remove, expr, new, new