code: def wigner_d_small(J, beta):
      """Return the small Wigner d matrix for angular momentum J.
  
      Explanation
      ===========
  
      J : An integer, half-integer, or SymPy symbol for the total angular
          momentum of the angular momentum space being rotated.
      beta : A real number representing the Euler angle of rotation about
          the so-called line of nodes. See [Edmonds74]_.
  
      Returns
      =======
  
      A matrix representing the corresponding Euler angle rotation( in the basis
      of eigenvectors of `J_z`).
  
      .. math ::
          \\mathcal{d}_{\\beta} = \\exp\\big( \\frac{i\\beta}{\\hbar} J_y\\big)
  
      The components are calculated using the general form [Edmonds74]_,
      equation 4.1.15.
  
      Examples
      ========
  
      >>> from sympy import Integer, symbols, pi, pprint
      >>> from sympy.physics.wigner import wigner_d_small
      >>> half = 1/Integer(2)
      >>> beta = symbols("beta", real=True)
      >>> pprint(wigner_d_small(half, beta), use_unicode=True)
      ⎡   ⎛β⎞      ⎛β⎞⎤
      ⎢cos⎜─⎟   sin⎜─⎟⎥
      ⎢   ⎝2⎠      ⎝2⎠⎥
      ⎢               ⎥
      ⎢    ⎛β⎞     ⎛β⎞⎥
      ⎢-sin⎜─⎟  cos⎜─⎟⎥
      ⎣    ⎝2⎠     ⎝2⎠⎦
  
      >>> pprint(wigner_d_small(2*half, beta), use_unicode=True)
      ⎡        2⎛β⎞              ⎛β⎞    ⎛β⎞           2⎛β⎞     ⎤
      ⎢     cos ⎜─⎟        √2⋅sin⎜─⎟⋅cos⎜─⎟        sin ⎜─⎟     ⎥
      ⎢         ⎝2⎠              ⎝2⎠    ⎝2⎠            ⎝2⎠     ⎥
      ⎢                                                        ⎥
      ⎢       ⎛β⎞    ⎛β⎞       2⎛β⎞      2⎛β⎞        ⎛β⎞    ⎛β⎞⎥
      ⎢-√2⋅sin⎜─⎟⋅cos⎜─⎟  - sin ⎜─⎟ + cos ⎜─⎟  √2⋅sin⎜─⎟⋅cos⎜─⎟⎥
      ⎢       ⎝2⎠    ⎝2⎠        ⎝2⎠       ⎝2⎠        ⎝2⎠    ⎝2⎠⎥
      ⎢                                                        ⎥
      ⎢        2⎛β⎞               ⎛β⎞    ⎛β⎞          2⎛β⎞     ⎥
      ⎢     sin ⎜─⎟        -√2⋅sin⎜─⎟⋅cos⎜─⎟       cos ⎜─⎟     ⎥
      ⎣         ⎝2⎠               ⎝2⎠    ⎝2⎠           ⎝2⎠     ⎦
  
      From table 4 in [Edmonds74]_
  
      >>> pprint(wigner_d_small(half, beta).subs({beta:pi/2}), use_unicode=True)
      ⎡ √2   √2⎤
      ⎢ ──   ──⎥
      ⎢ 2    2 ⎥
      ⎢        ⎥
      ⎢-√2   √2⎥
      ⎢────  ──⎥
      ⎣ 2    2 ⎦
  
      >>> pprint(wigner_d_small(2*half, beta).subs({beta:pi/2}),
      ... use_unicode=True)
      ⎡       √2      ⎤
      ⎢1/2    ──   1/2⎥
      ⎢       2       ⎥
      ⎢               ⎥
      ⎢-√2         √2 ⎥
      ⎢────   0    ── ⎥
      ⎢ 2          2  ⎥
      ⎢               ⎥
      ⎢      -√2      ⎥
      ⎢1/2   ────  1/2⎥
      ⎣       2       ⎦
  
      >>> pprint(wigner_d_small(3*half, beta).subs({beta:pi/2}),
      ... use_unicode=True)
      ⎡ √2    √6    √6   √2⎤
      ⎢ ──    ──    ──   ──⎥
      ⎢ 4     4     4    4 ⎥
      ⎢                    ⎥
      ⎢-√6   -√2    √2   √6⎥
      ⎢────  ────   ──   ──⎥
      ⎢ 4     4     4    4 ⎥
      ⎢                    ⎥
      ⎢ √6   -√2   -√2   √6⎥
      ⎢ ──   ────  ────  ──⎥
      ⎢ 4     4     4    4 ⎥
      ⎢                    ⎥
      ⎢-√2    √6   -√6   √2⎥
      ⎢────   ──   ────  ──⎥
      ⎣ 4     4     4    4 ⎦
  
      >>> pprint(wigner_d_small(4*half, beta).subs({beta:pi/2}),
      ... use_unicode=True)
      ⎡             √6            ⎤
      ⎢1/4   1/2    ──   1/2   1/4⎥
      ⎢             4             ⎥
      ⎢                           ⎥
      ⎢-1/2  -1/2   0    1/2   1/2⎥
      ⎢                           ⎥
      ⎢ √6                     √6 ⎥
      ⎢ ──    0    -1/2   0    ── ⎥
      ⎢ 4                      4  ⎥
      ⎢                           ⎥
      ⎢-1/2  1/2    0    -1/2  1/2⎥
      ⎢                           ⎥
      ⎢             √6            ⎥
      ⎢1/4   -1/2   ──   -1/2  1/4⎥
      ⎣             4             ⎦
  
      """
      M = [J - i for i in range(2 * J + 1)]
      d = zeros(2 * J + 1)
      for i, Mi in enumerate(M):
          for j, Mj in enumerate(M):
              # We get the maximum and minimum value of sigma.
              sigmamax = min([J - Mi, J - Mj])
              sigmamin = max([0, -Mi - Mj])
  
              dij = sqrt(
                  factorial(J + Mi)
                  * factorial(J - Mi)
                  / factorial(J + Mj)
                  / factorial(J - Mj)
              )
              terms = [
                  (-1) ** (J - Mi - s)
                  * binomial(J + Mj, J - Mi - s)
                  * binomial(J - Mj, s)
                  * cos(beta / 2) ** (2 * s + Mi + Mj)
                  * sin(beta / 2) ** (2 * J - 2 * s - Mj - Mi)
                  for s in range(sigmamin, sigmamax + 1)
              ]
  
              d[i, j] = dij * Add(*terms)
  
      return ImmutableMatrix(d)
  
imports: from sympy.concrete.summations import Sum
  from sympy.core.add import Add
  from sympy.core.numbers import int_valued
  from sympy.core.function import Function
  from sympy.core.numbers import I, Integer, pi
  from sympy.core.singleton import S
  from sympy.core.symbol import Dummy
  from sympy.core.sympify import sympify
  from sympy.functions.combinatorial.factorials import binomial, factorial
  from sympy.functions.elementary.complexes import re
  from sympy.functions.elementary.exponential import exp
  from sympy.functions.elementary.miscellaneous import sqrt
  from sympy.functions.elementary.trigonometric import cos, sin
  from sympy.functions.special.spherical_harmonics import Ynm
  from sympy.matrices.dense import zeros
  from sympy.matrices.immutable import ImmutableMatrix
  from sympy.utilities.misc import as_int
label_desc: Use image node_id 11 for calling a global function with example usage: wigner_d_small(J, beta) and returns: ImmutableMatrix