code: def _resnet(
      model_name: str,
      block: Type[Union[BasicBlock, Bottleneck]],
      layers: List[int],
      num_features: int,
      pretrained: Union[bool, str] = True,
      weights_paths: dict = {"supervised": None},
      **kwargs: Any,
  ) -> ResNet:
      pretrained_flag = (
          pretrained and isinstance(pretrained, bool)
      ) or (pretrained == "supervised")
  
      backbone = ResNet(block, layers, **kwargs)
      device = next(backbone.parameters()).get_device()
  
      model_weights = None
      if pretrained_flag:
          if "supervised" not in weights_paths:
              raise KeyError(
                  f"Supervised pretrained weights not available for {model_name}"
              )
  
          model_weights = load_state_dict_from_url(
              weights_paths["supervised"],
              map_location=torch.device("cpu")
              if device == -1
              else torch.device(device),
          )
  
          # for supervised pretrained weights
          model_weights.pop("fc.weight")
          model_weights.pop("fc.bias")
  
      if not pretrained_flag and isinstance(pretrained, str):
          if pretrained in weights_paths:
              model_weights = load_state_dict_from_url(
                  weights_paths[pretrained],
                  map_location=torch.device("cpu")
                  if device == -1
                  else torch.device(device),
              )
  
              if "classy_state_dict" in model_weights:
                  model_weights = model_weights["classy_state_dict"][
                      "base_model"
                  ]["model"]["trunk"]
                  model_weights = {
                      key.replace("_feature_blocks.", "")
                      if "_feature_blocks." in key
                      else key: val
                      for (key, val) in model_weights.items()
                  }
              else:
                  raise KeyError(
                      "Unrecognized state dict. Logic for loading the current state dict missing."
                  )
          else:
              raise KeyError(
                  f"Requested weights for {model_name} not available,"
                  f" choose from one of {weights_paths.keys()}"
              )
  
      if model_weights is not None:
          in_chans = backbone.conv1.weight.shape[1]
          model_weights["conv1.weight"] = adapt_input_conv(
              in_chans, model_weights["conv1.weight"]
          )
          backbone.load_state_dict(model_weights)
  
      return backbone, num_features
  
imports: from functools import partial
  from typing import Any, Callable, List, Optional, Type, Union
  import torch
  import torch.nn
  from torch import Tensor
  from torch.hub import load_state_dict_from_url
  from flash.core.registry import FlashRegistry
  from flash.core.utilities.imports import _TIMM_AVAILABLE
  from flash.core.utilities.url_error import catch_url_error
label_desc: Use image node_id 3 for calling a global function with example usage: _resnet(model_name, block, layers, num_features, pretrained, weights_paths) and returns: backbone,  num_features