class_docstr: A class representing group homomorphisms. Instantiate using `homomorphism()`.
  
  References
  ==========
  
  .. [1] Holt, D., Eick, B. and O'Brien, E. (2005). Handbook of computational group theory.
docstr: Apply `self` to `elem`.
docstr_tok: ["Apply","`","self","`","to","`","elem","`","."]
code: def _apply(self, elem):
      """
      Apply `self` to `elem`.
  
      """
      if elem not in self.domain:
          if isinstance(elem, (list, tuple)):
              return [self._apply(e) for e in elem]
          raise ValueError(
              "The supplied element does not belong to the domain"
          )
      if elem.is_identity:
          return self.codomain.identity
      else:
          images = self.images
          value = self.codomain.identity
          if isinstance(self.domain, PermutationGroup):
              gens = self.domain.generator_product(elem, original=True)
              for g in gens:
                  if g in self.images:
                      value = images[g] * value
                  else:
                      value = images[g**-1] ** -1 * value
          else:
              i = 0
              for _, p in elem.array_form:
                  if p < 0:
                      g = elem[i] ** -1
                  else:
                      g = elem[i]
                  value = value * images[g] ** p
                  i += abs(p)
      return value
  
imports: import itertools
  from sympy.combinatorics.fp_groups import FpGroup, FpSubgroup, simplify_presentation
  from sympy.combinatorics.free_groups import FreeGroup
  from sympy.combinatorics.perm_groups import PermutationGroup
  from sympy.core.intfunc import igcd
  from sympy.ntheory.factor_ import totient
  from sympy.core.singleton import S
label_desc: Use image node_id 7 for calling the GroupHomomorphism obj's underlying member method code with example usage: obj._apply(elem) and returns: value, self, unknown