code: def infer_imagenet_subset(model_or_cfg) -> Optional[str]:
      if isinstance(model_or_cfg, dict):
          num_classes = model_or_cfg.get("num_classes", None)
      else:
          num_classes = getattr(model_or_cfg, "num_classes", None)
          if not num_classes:
              pretrained_cfg = getattr(
                  model_or_cfg, "pretrained_cfg", {}
              )
              # FIXME at some point pretrained_cfg should include dataset-tag,
              # which will be more robust than a guess based on num_classes
              num_classes = pretrained_cfg.get("num_classes", None)
      if not num_classes or num_classes not in _NUM_CLASSES_TO_SUBSET:
          return None
      return _NUM_CLASSES_TO_SUBSET[num_classes]
  
file_path: pytorch-image-models/timm/data/imagenet_info.py
imports: import csv
  import os
  import pkgutil
  import re
  from typing import Dict, List, Optional, Union
  from .dataset_info import DatasetInfo
label_desc: Use image node_id 1 for calling a global function with example usage: infer_imagenet_subset(model_or_cfg) and returns: _NUM_CLASSES_TO_SUBSET, None