class_docstr: Base class for models in classy vision.
  
  A model refers either to a specific architecture (e.g. ResNet50) or a
  family of architectures (e.g. ResNet). Models can take arguments in the
  constructor in order to configure different behavior (e.g.
  hyperparameters).  Classy Models must implement :func:`from_config` in
  order to allow instantiation from a configuration file. Like regular
  PyTorch models, Classy Models must also implement :func:`forward`, where
  the bulk of the inference logic lives.
  
  Classy Models also have some advanced functionality for production
  fine-tuning systems. For example, we allow users to train a trunk
  model and then attach heads to the model via the attachable
  blocks.  Making your model support the trunk-heads paradigm is
  completely optional.
  
  NOTE: Advanced users can modify the behavior of their implemented models by
      specifying the `wrapper_cls` class attribute, which should be a class
      derived from :class:`ClassyModelWrapper` (see the documentation for that class
      for more information). Users can set it to `None` to skip wrapping their model
      and to make their model torchscriptable. This is set to
      :class:`ClassyModelHeadExecutorWrapper` by default.
class_docstr_tok: ["Base","class","for","models","in","classy","vision",".","A","model","refers","either","to","a","specific","architecture","(","e.g",".","ResNet50",")","or","a","family","of","architectures","(","e.g",".","ResNet",")",".","Models","can","take","arguments","in","the","constructor","in","order","to","configure","different","behavior","(","e.g",".","hyperparameters",")",".","Classy","Models","must","implement",":","func",":","`","from_config","`","in","order","to","allow","instantiation","from","a","configuration","file",".","Like","regular","PyTorch","models",",","Classy","Models","must","also","implement",":","func",":","`","forward","`",",","where","the","bulk","of","the","inference","logic","lives",".","Classy","Models","also","have","some","advanced","functionality","for","production","fine-tuning","systems",".","For","example",",","we","allow","users","to","train","a","trunk","model","and","then","attach","heads","to","the","model","via","the","attachable","blocks",".","Making","your","model","support","the","trunk-heads","paradigm","is","completely","optional",".","NOTE",":","Advanced","users","can","modify","the","behavior","of","their","implemented","models","by","specifying","the","`","wrapper_cls","`","class","attribute",",","which","should","be","a","class","derived","from",":","class",":","`","ClassyModelWrapper","`","(","see","the","documentation","for","that","class","for","more","information",")",".","Users","can","set","it","to","`","None","`","to","skip","wrapping","their","model","and","to","make","their","model","torchscriptable",".","This","is","set","to",":","class",":","`","ClassyModelHeadExecutorWrapper","`","by","default","."]
docstr: Attach all the heads to corresponding blocks.
  
  A head is expected to be a ClassyHead object. For more
  details, see :class:`classy_vision.heads.ClassyHead`.
  
  Args:
      heads (Dict): a mapping between attachable block name
          and a list of heads attached to that block. For
          example, if you have two different teams that want to
          attach two different heads for downstream classifiers to
          the 15th block, then they would use:
  
          .. code-block:: python
  
            heads = {"block15":
                [classifier_head1, classifier_head2]
            }
code: def set_heads(self, heads: Dict[str, List[ClassyHead]]):
      """Attach all the heads to corresponding blocks.
  
      A head is expected to be a ClassyHead object. For more
      details, see :class:`classy_vision.heads.ClassyHead`.
  
      Args:
          heads (Dict): a mapping between attachable block name
              and a list of heads attached to that block. For
              example, if you have two different teams that want to
              attach two different heads for downstream classifiers to
              the 15th block, then they would use:
  
              .. code-block:: python
  
                heads = {"block15":
                    [classifier_head1, classifier_head2]
                }
      """
      self.clear_heads()
  
      head_ids = set()
      for block_name, block_heads in heads.items():
          if not self._make_module_attachable(self, block_name):
              raise KeyError(f"{block_name} not found in the model")
          for head in block_heads:
              if head.unique_id in head_ids:
                  raise ValueError(
                      "head id {} already exists".format(head.unique_id)
                  )
              head_ids.add(head.unique_id)
          self._heads[block_name] = nn.ModuleDict(
              {head.unique_id: head for head in block_heads}
          )
  
imports: import copy
  import types
  from typing import Any, Dict, List, Optional, Tuple
  import torch
  import torch.nn
  from classy_vision.generic.util import log_class_usage
  from classy_vision.heads.classy_head import ClassyHead
  from .classy_block import ClassyBlock
label_desc: Use image node_id 15 for calling the ClassyModel obj's underlying member method code with example usage: obj.set_heads(heads) without return types