code: def generate_default_cfgs(
      cfgs: Dict[str, Union[Dict[str, Any], PretrainedCfg]]
  ):
      out = defaultdict(DefaultCfg)
      default_set = (
          set()
      )  # no tag and tags ending with * are prioritized as default
  
      for k, v in cfgs.items():
          if isinstance(v, dict):
              v = PretrainedCfg(**v)
          has_weights = v.has_weights
  
          model, tag = split_model_name_tag(k)
          is_default_set = model in default_set
          priority = (has_weights and not tag) or (
              tag.endswith("*") and not is_default_set
          )
          tag = tag.strip("*")
  
          default_cfg = out[model]
  
          if priority:
              default_cfg.tags.appendleft(tag)
              default_set.add(model)
          elif has_weights and not default_cfg.is_pretrained:
              default_cfg.tags.appendleft(tag)
          else:
              default_cfg.tags.append(tag)
  
          if has_weights:
              default_cfg.is_pretrained = True
  
          default_cfg.cfgs[tag] = v
  
      return out
  
imports: import fnmatch
  import re
  import sys
  import warnings
  from collections import defaultdict, deque
  from copy import deepcopy
  from dataclasses import replace
  from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Sequence, Union, Tuple
  from ._pretrained import PretrainedCfg, DefaultCfg
label_desc: Use image node_id 3 for calling a global function with example usage: generate_default_cfgs(cfgs) and returns: out