<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def impulse(dur=None, one=1., zero=0.):
 """ Impulse stream generator. Parameters dur : Duration, in number of samples; endless if not given. Returns ------- Stream that repeats "0.0" during a given time duration (if any) or endlessly, but starts with one (and only one) "1.0". """

  if dur is None or (isinf(dur) and dur > 0):
    yield one
    while True:
      yield zero
  elif dur >= .5:
    num_samples = int(dur - .5)
    yield one
    for x in xrange(num_samples):
      yield zero