code: def bernoulli_poly(n, x=None, polys=False):
      r"""Generates the Bernoulli polynomial `\operatorname{B}_n(x)`.
  
      `\operatorname{B}_n(x)` is the unique polynomial satisfying
  
      .. math :: \int_{x}^{x+1} \operatorname{B}_n(t) \,dt = x^n.
  
      Based on this, we have for nonnegative integer `s` and integer
      `a` and `b`
  
      .. math :: \sum_{k=a}^{b} k^s = \frac{\operatorname{B}_{s+1}(b+1) -
              \operatorname{B}_{s+1}(a)}{s+1}
  
      which is related to Jakob Bernoulli's original motivation for introducing
      the Bernoulli numbers, the values of these polynomials at `x = 1`.
  
      Examples
      ========
  
      >>> from sympy import summation
      >>> from sympy.abc import x
      >>> from sympy.polys import bernoulli_poly
      >>> bernoulli_poly(5, x)
      x**5 - 5*x**4/2 + 5*x**3/3 - x/6
  
      >>> def psum(p, a, b):
      ...     return (bernoulli_poly(p+1,b+1) - bernoulli_poly(p+1,a)) / (p+1)
      >>> psum(4, -6, 27)
      3144337
      >>> summation(x**4, (x, -6, 27))
      3144337
  
      >>> psum(1, 1, x).factor()
      x*(x + 1)/2
      >>> psum(2, 1, x).factor()
      x*(x + 1)*(2*x + 1)/6
      >>> psum(3, 1, x).factor()
      x**2*(x + 1)**2/4
  
      Parameters
      ==========
  
      n : int
          Degree of the polynomial.
      x : optional
      polys : bool, optional
          If True, return a Poly, otherwise (default) return an expression.
  
      See Also
      ========
  
      sympy.functions.combinatorial.numbers.bernoulli
  
      References
      ==========
  
      .. [1] https://en.wikipedia.org/wiki/Bernoulli_polynomials
      """
      return named_poly(
          n, dup_bernoulli, QQ, "Bernoulli polynomial", (x,), polys
      )
  
file_path: sympy/sympy/polys/appellseqs.py
imports: from sympy.polys.densearith import dup_mul_ground, dup_sub_ground, dup_quo_ground
  from sympy.polys.densetools import dup_eval, dup_integrate
  from sympy.polys.domains import ZZ, QQ
  from sympy.polys.polytools import named_poly
  from sympy.utilities import public
label_desc: Use image node_id 2 for calling a global function with example usage: bernoulli_poly(n, x, polys) and returns: named_poly