code: def legenp(ctx, n, m, z, type=2, **kwargs):
      # Legendre function, 1st kind
      n = ctx.convert(n)
      m = ctx.convert(m)
      # Faster
      if not m:
          return ctx.legendre(n, z, **kwargs)
      # TODO: correct evaluation at singularities
      if type == 2:
  
          def h(n, m):
              g = m * 0.5
              T = (
                  [1 + z, 1 - z],
                  [g, -g],
                  [],
                  [1 - m],
                  [-n, n + 1],
                  [1 - m],
                  0.5 * (1 - z),
              )
              return (T,)
  
          return ctx.hypercomb(h, [n, m], **kwargs)
      if type == 3:
  
          def h(n, m):
              g = m * 0.5
              T = (
                  [z + 1, z - 1],
                  [g, -g],
                  [],
                  [1 - m],
                  [-n, n + 1],
                  [1 - m],
                  0.5 * (1 - z),
              )
              return (T,)
  
          return ctx.hypercomb(h, [n, m], **kwargs)
      raise ValueError("requires type=2 or type=3")
  
file_path: catboost/contrib/python/mpmath/py3/mpmath/functions/orthogonal.py
imports: from .functions import defun, defun_wrapped
label_desc: Use image node_id 11 for calling a global function with example usage: legenp(ctx, n, m, z, type) and returns: ctx, ctx, ctx, T, T