code: def set_dropout_mode(
      model, dropout_layer_indexes: list, train_mode: bool
  ):
      """
      Function to change the mode of the dropout layers (bool: train_mode -> train or evaluation)
  
      Args:
          model: Pytorch model
          dropout_layer_indexes: Indexes of the dropout layers which should be activated
              Choose indices from : list(torch_model.modules())
          train_mode: boolean, true <=> train_mode, false <=> evaluation_mode
      """
  
      modules = list(
          model.modules()
      )  # list of all modules in the network.
  
      if len(dropout_layer_indexes) != 0:
          for index in dropout_layer_indexes:
              layer = modules[index]
              if layer.__class__.__name__.startswith("Dropout"):
                  if True == train_mode:
                      layer.train()
                  elif False == train_mode:
                      layer.eval()
              else:
                  raise KeyError(
                      "The passed index: {} is not a Dropout layer".format(
                          index
                      )
                  )
  
      else:
          for module in modules:
              if module.__class__.__name__.startswith("Dropout"):
                  if True == train_mode:
                      module.train()
                  elif False == train_mode:
                      module.eval()
  
imports: from collections.abc import Mapping
  from typing import Callable
  import numpy
  import torch
  from scipy.special import entr
  from sklearn.base import BaseEstimator
  from skorch.utils import to_numpy
  from modAL.utils.data import modALinput
  from modAL.utils.selection import multi_argmax, shuffled_argmax
label_desc: Use image node_id 12 for calling a global function with example usage: set_dropout_mode(model, dropout_layer_indexes, train_mode) without return types