code: def __init__(
      self,
      model: Union[nn.Module, nn.Sequential],
      layer: int = -1,
      flatten: bool = False,
  ) -> None:
      super().__init__()
      layers = list(model.children())[:layer]
      if flatten:
          layers += [nn.Flatten()]
      self.model = nn.Sequential(*layers)
  
file_path: alibi-detect/alibi_detect/cd/pytorch/preprocess.py
imports: from typing import Callable, Dict, Optional, Type, Union
  import numpy
  import torch
  import torch.nn
  from alibi_detect.utils.pytorch.prediction import predict_batch, predict_batch_transformer
  from alibi_detect.utils._types import TorchDeviceType
label_desc: Use image node_id 1 to create a new HiddenOutput object from inherited base classes: nn with example: obj = HiddenOutput(model, layer, flatten)