code: def duration_bool(b, rule, samplerate=None):
      
      if rule is None:
          return b
  
      slicelst = slicelist(b)
      b2 = np.array(b)
  
      if samplerate is None:
          samplerate = 1.0
  
      for sc in slicelst:
          dur = (sc.stop - sc.start) / samplerate  # NOQA
          if not eval(rule):
              b2[sc] = False
  
      return b2
docs: Mask the parts in b being True but does not meet the duration
      rules. Return an updated copy of b.
  
      b: 1d array with True or False elements.
  
      rule: str
          The rule including the string 'dur' to be evaled.
  
      samplerate: None or float
          Has an effect on the result.
  
      For each part of b that is True, a variable ``dur`` is set to the
      count of elements, or the result of (len(part) / samplerate). And then
      eval is called on the rule.