code: def build_model(config):
      """Builds a ClassyModel from a config.
  
      This assumes a 'name' key in the config which is used to determine what
      model class to instantiate. For instance, a config `{"name": "my_model",
      "foo": "bar"}` will find a class that was registered as "my_model"
      (see :func:`register_model`) and call .from_config on it."""
  
      assert (
          config["name"] in MODEL_REGISTRY
      ), f"unknown model: {config['name']}"
      model = MODEL_REGISTRY[config["name"]].from_config(config)
      if "heads" in config:
          heads = defaultdict(list)
          for head_config in config["heads"]:
              assert (
                  "fork_block" in head_config
              ), "Expect fork_block in config"
              fork_block = head_config["fork_block"]
              updated_config = copy.deepcopy(head_config)
              del updated_config["fork_block"]
  
              head = build_head(updated_config)
              heads[fork_block].append(head)
          model.set_heads(heads)
  
      return model
  
imports: import copy
  import traceback
  from collections import defaultdict
  from pathlib import Path
  from classy_vision.generic.registry_utils import import_all_modules
  from classy_vision.heads import build_head
  from .classy_model import ClassyModel
  from .anynet import AnyNet
  from .classy_block import ClassyBlock
  from .classy_model import ClassyModelWrapper, ClassyModelHeadExecutorWrapper
  from .densenet import DenseNet
  from .efficientnet import EfficientNet
  from .lecun_normal_init import lecun_normal_init
  from .mlp import MLP
  from .regnet import RegNet
  from .resnet import ResNet
  from .resnext import ResNeXt
  from .resnext3d import ResNeXt3D
  from .squeeze_and_excitation_layer import SqueezeAndExcitationLayer
  from .vision_transformer import VisionTransformer
label_desc: Use image node_id 2 for calling a global function with example usage: build_model(config) and returns: model