code: def ecm(n, B1=10000, B2=100000, max_curve=200, seed=1234):
      """Performs factorization using Lenstra's Elliptic curve method.
  
      This function repeatedly calls ``_ecm_one_factor`` to compute the factors
      of n. First all the small factors are taken out using trial division.
      Then ``_ecm_one_factor`` is used to compute one factor at a time.
  
      Parameters
      ==========
  
      n : Number to be Factored
      B1 : Stage 1 Bound. Must be an even number.
      B2 : Stage 2 Bound. Must be an even number.
      max_curve : Maximum number of curves generated
      seed : Initialize pseudorandom generator
  
      Examples
      ========
  
      >>> from sympy.ntheory import ecm
      >>> ecm(25645121643901801)
      {5394769, 4753701529}
      >>> ecm(9804659461513846513)
      {4641991, 2112166839943}
      """
      n = as_int(n)
      if B1 % 2 != 0 or B2 % 2 != 0:
          raise ValueError("both bounds must be even")
      _factors = set()
      for prime in sieve.primerange(1, 100000):
          if n % prime == 0:
              _factors.add(prime)
              while n % prime == 0:
                  n //= prime
      while n > 1:
          factor = _ecm_one_factor(n, B1, B2, max_curve, seed)
          if factor is None:
              raise ValueError("Increase the bounds")
          _factors.add(factor)
          n //= factor
  
      factors = set()
      for factor in _factors:
          if isprime(factor):
              factors.add(factor)
              continue
          factors |= ecm(factor)
      return factors
  
file_path: sympy/sympy/ntheory/ecm.py
imports: from math import log
  from sympy.core.random import _randint
  from sympy.external.gmpy import gcd, invert, sqrt
  from sympy.utilities.misc import as_int
  from .generate import sieve, primerange
  from .primetest import isprime
label_desc: Use image node_id 2 for calling a global function with example usage: ecm(n, B1, B2, max_curve, seed) and returns: factors