code: def _resolve_pretrained_source(pretrained_cfg):
      cfg_source = pretrained_cfg.get("source", "")
      pretrained_url = pretrained_cfg.get("url", None)
      pretrained_file = pretrained_cfg.get("file", None)
      pretrained_sd = pretrained_cfg.get("state_dict", None)
      hf_hub_id = pretrained_cfg.get("hf_hub_id", None)
  
      # resolve where to load pretrained weights from
      load_from = ""
      pretrained_loc = ""
      if cfg_source == "hf-hub" and has_hf_hub(necessary=True):
          # hf-hub specified as source via model identifier
          load_from = "hf-hub"
          assert hf_hub_id
          pretrained_loc = hf_hub_id
      else:
          # default source == timm or unspecified
          if pretrained_sd:
              # direct state_dict pass through is the highest priority
              load_from = "state_dict"
              pretrained_loc = pretrained_sd
              assert isinstance(pretrained_loc, dict)
          elif pretrained_file:
              # file load override is the second-highest priority if set
              load_from = "file"
              pretrained_loc = pretrained_file
          else:
              old_cache_valid = False
              if _USE_OLD_CACHE:
                  # prioritized old cached weights if exists and env var enabled
                  old_cache_valid = (
                      check_cached_file(pretrained_url)
                      if pretrained_url
                      else False
                  )
              if (
                  not old_cache_valid
                  and hf_hub_id
                  and has_hf_hub(necessary=True)
              ):
                  # hf-hub available as alternate weight source in default_cfg
                  load_from = "hf-hub"
                  pretrained_loc = hf_hub_id
              elif pretrained_url:
                  load_from = "url"
                  pretrained_loc = pretrained_url
  
      if load_from == "hf-hub" and pretrained_cfg.get(
          "hf_hub_filename", None
      ):
          # if a filename override is set, return tuple for location w/ (hub_id, filename)
          pretrained_loc = (
              pretrained_loc,
              pretrained_cfg["hf_hub_filename"],
          )
      return load_from, pretrained_loc
  
imports: import dataclasses
  import logging
  import os
  from copy import deepcopy
  from typing import Optional, Dict, Callable, Any, Tuple
  from torch import nn
  from torch.hub import load_state_dict_from_url
  from timm.models._features import FeatureListNet, FeatureHookNet
  from timm.models._features_fx import FeatureGraphNet
  from timm.models._helpers import load_state_dict
  from timm.models._hub import has_hf_hub, download_cached_file, check_cached_file, load_state_dict_from_hf
  from timm.models._manipulate import adapt_input_conv
  from timm.models._pretrained import PretrainedCfg
  from timm.models._prune import adapt_model_from_file
  from timm.models._registry import get_pretrained_cfg
label_desc: Use image node_id 1 for calling a global function with example usage: _resolve_pretrained_source(pretrained_cfg) and returns: load_from,  pretrained_loc