<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Function comb
Synopse
Create a grid of impulses image.
g = comb(shape, delta, offset)
g
Step1:  Examples
Step2:  Example 1
Step3:  Example 2
Step4:  Example 3
Step5:  Equation
One dimension
<ASSISTANT_TASK:>
Python Code:
import numpy as np
def comb(shape, delta, offset):
    shape = np.array(shape)
    assert shape.size <= 3
    g = np.zeros(shape) 
    if shape.size == 1:
        g[offset::delta] = 1
    elif shape.size == 2:
        g[offset[0]::delta[0], offset[1]::delta[1]] = 1
    elif shape.size == 3:
        g[offset[0]::delta[0], offset[1]::delta[1], offset[2]::delta[2]] = 1
    return g
Explanation: Function comb
Synopse
Create a grid of impulses image.
g = comb(shape, delta, offset)
g: Image. 
shape: Image. output image dimensions (1-D, 2-D or 3-D).
delta: Image. interval between the impulses in each dimension (1-D, 2-D or 3-D).
offset: Image. offset in each dimension (1-D, 2-D or 3-D).
End of explanation
testing = (__name__ == "__main__")
if testing:
    ! jupyter nbconvert --to python comb.ipynb
    import numpy as np
    import sys,os
    import matplotlib.image as mpimg
    ia898path = os.path.abspath('../../')
    if ia898path not in sys.path:
        sys.path.append(ia898path)
    import ia898.src as ia
Explanation: Examples
End of explanation
if testing:
    u1 = ia.comb(10, 3, 2)
    print('u1=',u1)
    u2 = ia.comb((10,), 3, 2)
    print('u2=',u2)
Explanation: Example 1
End of explanation
if testing:
    u3 = ia.comb((7,9), (1,2), (0,1))
    print('u3=\n',u3)
Explanation: Example 2
End of explanation
if testing:
    u4 = ia.comb((4,5,9), (2,1,2), (1,0,1))
    print(u4)
Explanation: Example 3
End of explanation
if testing:
    print('testing comb')
    print(repr(ia.comb(10, 3, 2)) == repr(np.array(
           [0., 0., 1., 0., 0., 1., 0., 0., 1., 0.])))
    print(repr(ia.comb((7,9), (3,4), (3,2))) == repr(np.array(
          [[0., 0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 1., 0., 0., 0., 1., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 0., 0., 0., 0., 0., 0., 0.],
           [0., 0., 1., 0., 0., 0., 1., 0., 0.]])))
Explanation: Equation
One dimension:
$$ \begin{matrix} u(x)=\sum _{i=0}^{\infty}\delta \left( x-\left( ki+o\right) \right)\
    x\in [0,S_0-1]
    \end{matrix}
    $$
$$\begin{matrix}
    where\quad \delta (i)=\left{ \begin{array}{ll}
    1, & i=0\
    0, & otherwise
    \end{array}\right.
    \end{matrix}
    $$
N-dimension:
$$
\begin{matrix}
u\left( x_{0},x_{1},\cdots ,x_{N-1}\right) =\sum {i{0}=0}^{\infty}\sum {i{1}=0}^{\infty}\cdots \sum {i{N-1}=0}^{\infty}\delta \left( x_{0}-\left( k_{0}i_{0}+o_{0}\right) ,x_{1}-\left( k_{1}i_{1}+o_{1}\right) ,\cdots ,x_{N-1}-\left(k_{N-1}i_{N-1}+o_{N-1}\right) \right)\
    \left( x_{0},x_{1},\cdots ,x_{N-1}\right) \in \left[ \left( 0,0,\cdots ,0\right) ,\left( S_{0}-1,S_{1}-1,\cdots ,S_{N-1}-1\right) \right]
    \end{matrix} $$
$$\begin{matrix}
    where\quad \delta (i_0,i_1,\ldots,i_{N-1})=\left{ \begin{array}{ll}
    1, & i_0=i_1=i_2=\ldots=i_{N-1}=0\
    0, & otherwise
    \end{array}\right.
    \end{matrix}
    $$
End of explanation
<END_TASK>