code: def list_models(
      filter: Union[str, List[str]] = "",
      module: str = "",
      pretrained: bool = False,
      exclude_filters: Union[str, List[str]] = "",
      name_matches_cfg: bool = False,
      include_tags: Optional[bool] = None,
  ) -> List[str]:
      """Return list of available model names, sorted alphabetically
  
      Args:
          filter - Wildcard filter string that works with fnmatch
          module - Limit model selection to a specific submodule (ie 'vision_transformer')
          pretrained - Include only models with valid pretrained weights if True
          exclude_filters - Wildcard filters to exclude models after including them with filter
          name_matches_cfg - Include only models w/ model_name matching default_cfg name (excludes some aliases)
          include_tags - Include pretrained tags in model names (model.tag). If None, defaults
              set to True when pretrained=True else False (default: None)
  
      Returns:
          models - The sorted list of models
  
      Example:
          model_list('gluon_resnet*') -- returns all models starting with 'gluon_resnet'
          model_list('*resnext*, 'resnet') -- returns all models with 'resnext' in 'resnet' module
      """
      if filter:
          include_filters = (
              filter if isinstance(filter, (tuple, list)) else [filter]
          )
      else:
          include_filters = []
  
      if include_tags is None:
          # FIXME should this be default behaviour? or default to include_tags=True?
          include_tags = pretrained
  
      all_models: Set[str] = (
          _module_to_models[module]
          if module
          else set(_model_entrypoints.keys())
      )
      all_models = (
          all_models - _deprecated_models.keys()
      )  # remove deprecated models from listings
  
      if include_tags:
          # expand model names to include names w/ pretrained tags
          models_with_tags: Set[str] = set()
          for m in all_models:
              models_with_tags.update(_model_with_tags[m])
          all_models = models_with_tags
          # expand include and exclude filters to include a '.*' for proper match if no tags in filter
          include_filters = [
              ef for f in include_filters for ef in _expand_filter(f)
          ]
          exclude_filters = [
              ef for f in exclude_filters for ef in _expand_filter(f)
          ]
  
      if include_filters:
          models: Set[str] = set()
          for f in include_filters:
              include_models = fnmatch.filter(
                  all_models, f
              )  # include these models
              if len(include_models):
                  models = models.union(include_models)
      else:
          models = all_models
  
      if exclude_filters:
          if not isinstance(exclude_filters, (tuple, list)):
              exclude_filters = [exclude_filters]
          for xf in exclude_filters:
              exclude_models = fnmatch.filter(
                  models, xf
              )  # exclude these models
              if len(exclude_models):
                  models = models.difference(exclude_models)
  
      if pretrained:
          models = _model_has_pretrained.intersection(models)
  
      if name_matches_cfg:
          models = set(_model_pretrained_cfgs).intersection(models)
  
      return sorted(models, key=_natural_key)
  
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 9 for calling a global function with example usage: list_models(filter, module, pretrained, exclude_filters, name_matches_cfg, include_tags) and returns: sorted