docs: def parse_duration(value):
      """
      >>> parse_duration('1h')
      3600
      >>> parse_duration('1m')
      60
      >>> parse_duration('1m 2s')
      62
      >>> parse_duration('1')
      1
  
      """
      if isinstance(value, (int, float)):
          return value
      elif not pattern_valid.fullmatch(value):
          raise ValueError(value)
  
      result = 0
      for m in pattern.finditer(value):
          v = m.groupdict()
          n = int(v['n'])
          unit = v['unit']
          if not unit:
              result += n
          elif unit in durations:
              result += n * durations[unit]
          else:
              raise ValueError(value)
      return result