code: def blocks(intervals, amplitudes=None, name=None):
      """Step function based on a sequence of intervals.
  
      Parameters
      ----------
      intervals : (S,) sequence of (2,) sequences
         Sequence (S0, S1, ... S(N-1)) of sequences, where S0 (etc) are
         sequences of length 2, giving 'on' and 'off' times of block
      amplitudes : (S,) sequence of float, optional
         Optional amplitudes for each block. Defaults to 1.
      name : None or str, optional
         Name of the convolved function in the resulting expression.
         Defaults to one created by ``utils.interp``.
  
      Returns
      -------
      b_of_t : sympy expr
         Sympy expression b(t) where b is a sympy anonymous function of
         time that implements the block step function
  
      Examples
      --------
      >>> on_off = [[1,2],[3,4]]
      >>> tval = np.array([0.4,1.4,2.4,3.4])
      >>> b = blocks(on_off)
      >>> lam = lambdify_t(b)
      >>> lam(tval)
      array([ 0.,  1.,  0.,  1.])
      >>> b = blocks(on_off, amplitudes=[3,5])
      >>> lam = lambdify_t(b)
      >>> lam(tval)
      array([ 0.,  3.,  0.,  5.])
      """
      t = [-np.inf]
      v = [0]
      if amplitudes is None:
          amplitudes = itertools.cycle([1])
      for _t, a in zip(intervals, amplitudes):
          t += list(_t)
          v += [a, 0]
      t.append(np.inf)
      v.append(0)
      return step_function(t, v, name=name)
  
imports: import itertools
  import numpy
  import sympy
  from scipy.interpolate import interp1d
  from sympy import DiracDelta, Symbol
  from sympy.utilities.lambdify import implemented_function, lambdify
  from nipy.algorithms.statistics.formula.formulae import Formula, Term
label_desc: Use image node_id 8 for calling a global function with example usage: blocks(intervals, amplitudes, name) and returns: step_function