code: def _discrete_log_pollard_rho(
      n, a, b, order=None, retries=10, rseed=None
  ):
      """
      Pollard's Rho algorithm for computing the discrete logarithm of ``a`` to
      the base ``b`` modulo ``n``.
  
      It is a randomized algorithm with the same expected running time as
      ``_discrete_log_shanks_steps``, but requires a negligible amount of memory.
  
      Examples
      ========
  
      >>> from sympy.ntheory.residue_ntheory import _discrete_log_pollard_rho
      >>> _discrete_log_pollard_rho(227, 3**7, 3)
      7
  
      See Also
      ========
  
      discrete_log
  
      References
      ==========
  
      .. [1] "Handbook of applied cryptography", Menezes, A. J., Van, O. P. C., &
          Vanstone, S. A. (1997).
      """
      a %= n
      b %= n
  
      if order is None:
          order = n_order(b, n)
      randint = _randint(rseed)
  
      for i in range(retries):
          aa = randint(1, order - 1)
          ba = randint(1, order - 1)
          xa = pow(b, aa, n) * pow(a, ba, n) % n
  
          c = xa % 3
          if c == 0:
              xb = a * xa % n
              ab = aa
              bb = (ba + 1) % order
          elif c == 1:
              xb = xa * xa % n
              ab = (aa + aa) % order
              bb = (ba + ba) % order
          else:
              xb = b * xa % n
              ab = (aa + 1) % order
              bb = ba
  
          for j in range(order):
              c = xa % 3
              if c == 0:
                  xa = a * xa % n
                  ba = (ba + 1) % order
              elif c == 1:
                  xa = xa * xa % n
                  aa = (aa + aa) % order
                  ba = (ba + ba) % order
              else:
                  xa = b * xa % n
                  aa = (aa + 1) % order
  
              c = xb % 3
              if c == 0:
                  xb = a * xb % n
                  bb = (bb + 1) % order
              elif c == 1:
                  xb = xb * xb % n
                  ab = (ab + ab) % order
                  bb = (bb + bb) % order
              else:
                  xb = b * xb % n
                  ab = (ab + 1) % order
  
              c = xb % 3
              if c == 0:
                  xb = a * xb % n
                  bb = (bb + 1) % order
              elif c == 1:
                  xb = xb * xb % n
                  ab = (ab + ab) % order
                  bb = (bb + bb) % order
              else:
                  xb = b * xb % n
                  ab = (ab + 1) % order
  
              if xa == xb:
                  r = (ba - bb) % order
                  try:
                      e = invert(r, order) * (ab - aa) % order
                      if (pow(b, e, n) - a) % n == 0:
                          return e
                  except ZeroDivisionError:
                      pass
                  break
      raise ValueError("Pollard's Rho failed to find logarithm")
  
imports: from __future__ import annotations
  from sympy.external.gmpy import gcd, lcm, invert, sqrt, legendre, jacobi, kronecker, bit_scan1, remove
  from sympy.polys import Poly
  from sympy.polys.domains import ZZ
  from sympy.polys.galoistools import gf_crt1, gf_crt2, linear_congruence, gf_csolve
  from .primetest import isprime
  from .factor_ import factorint, _perfect_power
  from .modular import crt
  from sympy.utilities.decorator import deprecated
  from sympy.utilities.memoization import recurrence_memo
  from sympy.utilities.misc import as_int
  from sympy.utilities.iterables import iproduct
  from sympy.core.random import _randint, randint
  from itertools import product
label_desc: Use image node_id 25 for calling a global function with example usage: _discrete_log_pollard_rho(n, a, b, order, retries, rseed) and returns: e