code: def group_by_key(dirnames, key):
      
      groups = defaultdict(lambda: [])
      for dirname in dirnames:
          m = get_recent_model(dirname)
          groups[m.__dict__[key]].append(dirname)
      return dict(groups)
docs: Group a set of output directories according to a model parameter.
  
      Parameters
      ----------
      dirnames: list[str]
          Output directories
      key: various
          A field of a :class:`Model` instance.
  
      Returns
      -------
      groups: dict[various: list[str]]
          For each value of `key` that is found at least once in the models, a
          list of the output directories where `key` is that value.