class_docstr: Overall parent module that holds the dictionary of expert autoencoders
  and expert classifiers.
class_docstr_tok: ["Overall","parent","module","that","holds","the","dictionary","of","expert","autoencoders","and","expert","classifiers","."]
docstr: :param shape: shape of the input layer
  :param device: gpu or cpu
  :param arch: the architecture to use from torchvision.models,
  defaults to "alexnet"
  :param pretrained_flag: determines if torchvision model is pre-trained,
  defaults to True
  :param output_layer_name: output layer of the feature backbone,
  defaults to "features"
docstr_tok: [":","param","shape",":","shape","of","the","input","layer",":","param","device",":","gpu","or","cpu",":","param","arch",":","the","architecture","to","use","from","torchvision.models",",","defaults","to","``","alexnet","''",":","param","pretrained_flag",":","determines","if","torchvision","model","is","pre-trained",",","defaults","to","True",":","param","output_layer_name",":","output","layer","of","the","feature","backbone",",","defaults","to","``","features","''"]
code: def __init__(
      self,
      shape,
      device,
      arch="alexnet",
      pretrained_flag=True,
      output_layer_name="features",
  ):
      """
      :param shape: shape of the input layer
      :param device: gpu or cpu
      :param arch: the architecture to use from torchvision.models,
      defaults to "alexnet"
      :param pretrained_flag: determines if torchvision model is pre-trained,
      defaults to True
      :param output_layer_name: output layer of the feature backbone,
      defaults to "features"
      """
      super().__init__()
  
      # Store variables
      self.shape = shape
      self.arch = arch
      self.pretrained_flag = pretrained_flag
      self.device = device
  
      # Dictionary for autoencoders
      # {task, autoencoder}
      self.autoencoder_dict = nn.ModuleDict()
  
      # Dictionary for experts
      # {task, expert}
      self.expert_dict = nn.ModuleDict()
  
      # Initialize an expert with pretrained AlexNet
      self.expert = (
          models.__dict__[arch](
              weights=(
                  "AlexNet_Weights.IMAGENET1K_V1"
                  if pretrained_flag
                  else "AlexNet_Weights.NONE"
              )
          )
          .to(device)
          .eval()
      )
  
imports: from collections import OrderedDict
  from copy import deepcopy
  import torch
  import torch.nn
  import torch.nn.functional
  from torch import sigmoid
  from torch.nn.functional import mse_loss, softmax
  from torchvision import transforms
  import torchvision.models
  from .utils import FeatureExtractorBackbone
  from avalanche.models import MultiTaskModule
  from avalanche.models.utils import Flatten
  from avalanche.benchmarks.scenarios.generic_scenario import CLExperience
label_desc: Use image node_id 1 to create a new ExpertGate object from inherited base classes: nn with example: obj = ExpertGate(shape, device, arch, pretrained_flag, output_layer_name)