code: def legendre(ctx, n, x, **kwargs):
      if ctx.isint(n):
          n = int(n)
          # Accuracy near zeros
          if (n + (n < 0)) & 1:
              if not x:
                  return x
              mag = ctx.mag(x)
              if mag < -2 * ctx.prec - 10:
                  return x
              if mag < -5:
                  ctx.prec += -mag
      return ctx.hyp2f1(-n, n + 1, 1, (1 - x) / 2, **kwargs)
  
file_path: catboost/contrib/python/mpmath/py3/mpmath/functions/orthogonal.py
imports: from .functions import defun, defun_wrapped
label_desc: Use image node_id 10 for calling a global function with example usage: legendre(ctx, n, x) and returns: ctx, x, x