class_docstr: Estimator class for PyTorch models.
class_docstr_tok: ["Estimator","class","for","PyTorch","models","."]
docstr: Set all layers that are an instance of `layerinfo` into training or evaluation mode.
  
  :param train: False for evaluation mode.
  :param layerinfo: List of module types.
docstr_tok: ["Set","all","layers","that","are","an","instance","of","`","layerinfo","`","into","training","or","evaluation","mode",".",":","param","train",":","False","for","evaluation","mode",".",":","param","layerinfo",":","List","of","module","types","."]
code: def _set_layer(
      self, train: bool, layerinfo: List["torch.nn.modules.Module"]
  ) -> None:
      """
      Set all layers that are an instance of `layerinfo` into training or evaluation mode.
  
      :param train: False for evaluation mode.
      :param layerinfo: List of module types.
      """
      import torch
  
      assert all((issubclass(layer, torch.nn.modules.Module) for layer in layerinfo))  # type: ignore
  
      def set_train(layer, layerinfo=layerinfo):
          "Set layer into training mode if instance of `layerinfo`."
          if isinstance(layer, tuple(layerinfo)):
              layer.train()
  
      def set_eval(layer, layerinfo=layerinfo):
          "Set layer into evaluation mode if instance of `layerinfo`."
          if isinstance(layer, tuple(layerinfo)):
              layer.eval()
  
      if train:
          self._model.apply(set_train)
      else:
          self._model.apply(set_eval)
  
file_path: adversarial-robustness-toolbox/art/estimators/pytorch.py
imports: import logging
  from typing import TYPE_CHECKING, Any, List, Tuple
  import numpy
  from art.estimators.estimator import BaseEstimator, LossGradientsMixin, NeuralNetworkMixin
label_desc: Use image node_id 9 for calling the PyTorchEstimator obj's underlying member method code with example usage: obj._set_layer(train, layerinfo) without return types