class_docstr: FastFlow.
  
  Unsupervised Anomaly Detection and Localization via 2D Normalizing Flows.
  
  Args:
      input_size (tuple[int, int]): Model input size.
      backbone (str): Backbone CNN network
      pre_trained (bool, optional): Boolean to check whether to use a pre_trained backbone.
      flow_steps (int, optional): Flow steps.
      conv3x3_only (bool, optinoal): Use only conv3x3 in fast_flow model. Defaults to False.
      hidden_ratio (float, optional): Ratio to calculate hidden var channels. Defaults to 1.0.
  
  Raises:
      ValueError: When the backbone is not supported.
class_docstr_tok: ["FastFlow",".","Unsupervised","Anomaly","Detection","and","Localization","via","2D","Normalizing","Flows",".","Args",":","input_size","(","tuple","[","int",",","int","]",")",":","Model","input","size",".","backbone","(","str",")",":","Backbone","CNN","network","pre_trained","(","bool",",","optional",")",":","Boolean","to","check","whether","to","use","a","pre_trained","backbone",".","flow_steps","(","int",",","optional",")",":","Flow","steps",".","conv3x3_only","(","bool",",","optinoal",")",":","Use","only","conv3x3","in","fast_flow","model",".","Defaults","to","False",".","hidden_ratio","(","float",",","optional",")",":","Ratio","to","calculate","hidden","var","channels",".","Defaults","to","1.0",".","Raises",":","ValueError",":","When","the","backbone","is","not","supported","."]
code: def __init__(
      self,
      input_size: tuple[int, int],
      backbone: str,
      pre_trained: bool = True,
      flow_steps: int = 8,
      conv3x3_only: bool = False,
      hidden_ratio: float = 1.0,
  ) -> None:
      super().__init__()
  
      self.input_size = input_size
  
      if backbone in (
          "cait_m48_448",
          "deit_base_distilled_patch16_384",
      ):
          self.feature_extractor = timm.create_model(
              backbone, pretrained=pre_trained
          )
          channels = [768]
          scales = [16]
      elif backbone in ("resnet18", "wide_resnet50_2"):
          self.feature_extractor = timm.create_model(
              backbone,
              pretrained=pre_trained,
              features_only=True,
              out_indices=[1, 2, 3],
          )
          channels = self.feature_extractor.feature_info.channels()
          scales = self.feature_extractor.feature_info.reduction()
  
          # for transformers, use their pretrained norm w/o grad
          # for resnets, self.norms are trainable LayerNorm
          self.norms = nn.ModuleList()
          for channel, scale in zip(channels, scales):
              self.norms.append(
                  nn.LayerNorm(
                      [
                          channel,
                          int(input_size[0] / scale),
                          int(input_size[1] / scale),
                      ],
                      elementwise_affine=True,
                  )
              )
      else:
          raise ValueError(
              f"Backbone {backbone} is not supported. List of available backbones are "
              "[cait_m48_448, deit_base_distilled_patch16_384, resnet18, wide_resnet50_2]."
          )
  
      for parameter in self.feature_extractor.parameters():
          parameter.requires_grad = False
  
      self.fast_flow_blocks = nn.ModuleList()
      for channel, scale in zip(channels, scales):
          self.fast_flow_blocks.append(
              create_fast_flow_block(
                  input_dimensions=[
                      channel,
                      int(input_size[0] / scale),
                      int(input_size[1] / scale),
                  ],
                  conv3x3_only=conv3x3_only,
                  hidden_ratio=hidden_ratio,
                  flow_steps=flow_steps,
              )
          )
      self.anomaly_map_generator = AnomalyMapGenerator(
          input_size=input_size
      )
  
file_path: anomalib/src/anomalib/models/fastflow/torch_model.py
imports: from __future__ import annotations
  from typing import Callable
  import timm
  import torch
  from FrEIA.framework import SequenceINN
  from timm.models.cait import Cait
  from timm.models.vision_transformer import VisionTransformer
  from torch import Tensor, nn
  from anomalib.models.components.flow import AllInOneBlock
  from anomalib.models.fastflow.anomaly_map import AnomalyMapGenerator
label_desc: Use image node_id 1 to create a new FastflowModel object from inherited base classes: nn with example: obj = FastflowModel(input_size, backbone, pre_trained, flow_steps, conv3x3_only, hidden_ratio)