class_docstr: Multiple Instance Learning (MIL) model, with a backbone classification model.
  Currently, it only works for 2D images, a typical use case is for classification of the
  digital pathology whole slide images. The expected shape of input data is `[B, N, C, H, W]`,
  where `B` is the batch_size of PyTorch Dataloader and `N` is the number of instances
  extracted from every original image in the batch. A tutorial example is available at:
  https://github.com/Project-MONAI/tutorials/tree/master/pathology/multiple_instance_learning.
  
  Args:
      num_classes: number of output classes.
      mil_mode: MIL algorithm, available values (Defaults to ``"att"``):
  
          - ``"mean"`` - average features from all instances, equivalent to pure CNN (non MIL).
          - ``"max"`` - retain only the instance with the max probability for loss calculation.
          - ``"att"`` - attention based MIL https://arxiv.org/abs/1802.04712.
          - ``"att_trans"`` - transformer MIL https://arxiv.org/abs/2111.01556.
          - ``"att_trans_pyramid"`` - transformer pyramid MIL https://arxiv.org/abs/2111.01556.
  
      pretrained: init backbone with pretrained weights, defaults to ``True``.
      backbone: Backbone classifier CNN (either ``None``, a ``nn.Module`` that returns features,
          or a string name of a torchvision model).
          Defaults to ``None``, in which case ResNet50 is used.
      backbone_num_features: Number of output features of the backbone CNN
          Defaults to ``None`` (necessary only when using a custom backbone)
      trans_blocks: number of the blocks in `TransformEncoder` layer.
      trans_dropout: dropout rate in `TransformEncoder` layer.
code: def forward(
      self, x: torch.Tensor, no_head: bool = False
  ) -> torch.Tensor:
      sh = x.shape
      x = x.reshape(sh[0] * sh[1], sh[2], sh[3], sh[4])
  
      x = self.net(x)
      x = x.reshape(sh[0], sh[1], -1)
  
      if not no_head:
          x = self.calc_head(x)
  
      return x
  
file_path: MONAI/monai/networks/nets/milmodel.py
imports: from __future__ import annotations
  from typing import cast
  import torch
  import torch.nn
  from monai.utils.module import optional_import
label_desc: Use image node_id 3 for calling the MILModel obj's underlying member method code with example usage: obj.forward(x, no_head) and returns: x