Swin3D#

pydantic model vision_architectures.nets.swin_3d.Swin3DPatchMergingConfig[source]#

Bases: CustomBaseModel

Show JSON schema
{
   "title": "Swin3DPatchMergingConfig",
   "type": "object",
   "properties": {
      "out_dim_ratio": {
         "title": "Out Dim Ratio",
         "type": "integer"
      },
      "merge_window_size": {
         "maxItems": 3,
         "minItems": 3,
         "prefixItems": [
            {
               "type": "integer"
            },
            {
               "type": "integer"
            },
            {
               "type": "integer"
            }
         ],
         "title": "Merge Window Size",
         "type": "array"
      }
   },
   "required": [
      "out_dim_ratio",
      "merge_window_size"
   ]
}

Config:
  • arbitrary_types_allowed: bool = True

  • extra: str = ignore

  • validate_default: bool = True

  • validate_assignment: bool = True

  • validate_return: bool = True

Fields:
Validators:
field out_dim_ratio: int [Required]#
Validated by:
field merge_window_size: tuple[int, int, int] [Required]#
Validated by:
validator validate_before  »  all fields[source]#

Base class method for validating data before creating the model.

pydantic model vision_architectures.nets.swin_3d.Swin3DPatchSplittingConfig[source]#

Bases: CustomBaseModel

Show JSON schema
{
   "title": "Swin3DPatchSplittingConfig",
   "type": "object",
   "properties": {
      "out_dim_ratio": {
         "title": "Out Dim Ratio",
         "type": "integer"
      },
      "final_window_size": {
         "maxItems": 3,
         "minItems": 3,
         "prefixItems": [
            {
               "type": "integer"
            },
            {
               "type": "integer"
            },
            {
               "type": "integer"
            }
         ],
         "title": "Final Window Size",
         "type": "array"
      }
   },
   "required": [
      "out_dim_ratio",
      "final_window_size"
   ]
}

Config:
  • arbitrary_types_allowed: bool = True

  • extra: str = ignore

  • validate_default: bool = True

  • validate_assignment: bool = True

  • validate_return: bool = True

Fields:
Validators:
field out_dim_ratio: int [Required]#
Validated by:
field final_window_size: tuple[int, int, int] [Required]#
Validated by:
validator validate_before  »  all fields[source]#

Base class method for validating data before creating the model.

pydantic model vision_architectures.nets.swin_3d.Swin3DStageConfig[source]#

Bases: Attention3DWithMLPConfig

Show JSON schema
{
   "title": "Swin3DStageConfig",
   "type": "object",
   "properties": {
      "dim": {
         "default": 0,
         "description": "dim at which attention is performed",
         "title": "Dim",
         "type": "integer"
      },
      "mlp_ratio": {
         "default": 4,
         "title": "Mlp Ratio",
         "type": "integer"
      },
      "activation": {
         "default": "gelu",
         "title": "Activation",
         "type": "string"
      },
      "mlp_drop_prob": {
         "default": 0.0,
         "title": "Mlp Drop Prob",
         "type": "number"
      },
      "num_heads": {
         "description": "Number of query heads",
         "title": "Num Heads",
         "type": "integer"
      },
      "ratio_q_to_kv_heads": {
         "default": 1,
         "title": "Ratio Q To Kv Heads",
         "type": "integer"
      },
      "logit_scale_learnable": {
         "default": false,
         "title": "Logit Scale Learnable",
         "type": "boolean"
      },
      "attn_drop_prob": {
         "default": 0.0,
         "title": "Attn Drop Prob",
         "type": "number"
      },
      "proj_drop_prob": {
         "default": 0.0,
         "title": "Proj Drop Prob",
         "type": "number"
      },
      "max_attention_batch_size": {
         "default": -1,
         "description": "Runs attention by splitting the inputs into chunks of this size. 0 means no chunking. Useful for large inputs during inference.",
         "title": "Max Attention Batch Size",
         "type": "integer"
      },
      "norm_location": {
         "default": "post",
         "enum": [
            "pre",
            "post"
         ],
         "title": "Norm Location",
         "type": "string"
      },
      "layer_norm_eps": {
         "default": 1e-06,
         "title": "Layer Norm Eps",
         "type": "number"
      },
      "depth": {
         "title": "Depth",
         "type": "integer"
      },
      "window_size": {
         "maxItems": 3,
         "minItems": 3,
         "prefixItems": [
            {
               "type": "integer"
            },
            {
               "type": "integer"
            },
            {
               "type": "integer"
            }
         ],
         "title": "Window Size",
         "type": "array"
      },
      "use_relative_position_bias": {
         "default": false,
         "title": "Use Relative Position Bias",
         "type": "boolean"
      },
      "patch_merging": {
         "anyOf": [
            {
               "$ref": "#/$defs/Swin3DPatchMergingConfig"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "patch_splitting": {
         "anyOf": [
            {
               "$ref": "#/$defs/Swin3DPatchSplittingConfig"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      },
      "in_dim": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "In Dim"
      },
      "out_dim": {
         "anyOf": [
            {
               "type": "integer"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Out Dim"
      }
   },
   "$defs": {
      "Swin3DPatchMergingConfig": {
         "properties": {
            "out_dim_ratio": {
               "title": "Out Dim Ratio",
               "type": "integer"
            },
            "merge_window_size": {
               "maxItems": 3,
               "minItems": 3,
               "prefixItems": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  }
               ],
               "title": "Merge Window Size",
               "type": "array"
            }
         },
         "required": [
            "out_dim_ratio",
            "merge_window_size"
         ],
         "title": "Swin3DPatchMergingConfig",
         "type": "object"
      },
      "Swin3DPatchSplittingConfig": {
         "properties": {
            "out_dim_ratio": {
               "title": "Out Dim Ratio",
               "type": "integer"
            },
            "final_window_size": {
               "maxItems": 3,
               "minItems": 3,
               "prefixItems": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  }
               ],
               "title": "Final Window Size",
               "type": "array"
            }
         },
         "required": [
            "out_dim_ratio",
            "final_window_size"
         ],
         "title": "Swin3DPatchSplittingConfig",
         "type": "object"
      }
   },
   "required": [
      "num_heads",
      "depth",
      "window_size"
   ]
}

Config:
  • arbitrary_types_allowed: bool = True

  • extra: str = ignore

  • validate_default: bool = True

  • validate_assignment: bool = True

  • validate_return: bool = True

Fields:
Validators:

field depth: int [Required]#
Validated by:
field window_size: tuple[int, int, int] [Required]#
Validated by:
field use_relative_position_bias: bool = False#
Validated by:
field patch_merging: Swin3DPatchMergingConfig | None = None#
Validated by:
field patch_splitting: Swin3DPatchSplittingConfig | None = None#
Validated by:
field in_dim: int | None = None#
Validated by:
field dim: int = 0#

dim at which attention is performed

Validated by:
field out_dim: int | None = None#
Validated by:
field logit_scale_learnable: bool = False#
Validated by:
get_out_patch_size(in_patch_size)[source]#
get_in_patch_size(out_patch_size)[source]#
pydantic model vision_architectures.nets.swin_3d.Swin3DConfig[source]#

Bases: CustomBaseModel

Show JSON schema
{
   "title": "Swin3DConfig",
   "type": "object",
   "properties": {
      "dim": {
         "title": "Dim",
         "type": "integer"
      },
      "in_channels": {
         "title": "In Channels",
         "type": "integer"
      },
      "patch_size": {
         "maxItems": 3,
         "minItems": 3,
         "prefixItems": [
            {
               "type": "integer"
            },
            {
               "type": "integer"
            },
            {
               "type": "integer"
            }
         ],
         "title": "Patch Size",
         "type": "array"
      },
      "image_size": {
         "anyOf": [
            {
               "maxItems": 3,
               "minItems": 3,
               "prefixItems": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  }
               ],
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "required for learnable absolute position embeddings",
         "title": "Image Size"
      },
      "stages": {
         "items": {
            "$ref": "#/$defs/Swin3DStageConfig"
         },
         "title": "Stages",
         "type": "array"
      },
      "drop_prob": {
         "default": 0.0,
         "title": "Drop Prob",
         "type": "number"
      },
      "embed_spacing_info": {
         "default": false,
         "title": "Embed Spacing Info",
         "type": "boolean"
      },
      "use_absolute_position_embeddings": {
         "default": true,
         "title": "Use Absolute Position Embeddings",
         "type": "boolean"
      },
      "learnable_absolute_position_embeddings": {
         "default": false,
         "title": "Learnable Absolute Position Embeddings",
         "type": "boolean"
      }
   },
   "$defs": {
      "Swin3DPatchMergingConfig": {
         "properties": {
            "out_dim_ratio": {
               "title": "Out Dim Ratio",
               "type": "integer"
            },
            "merge_window_size": {
               "maxItems": 3,
               "minItems": 3,
               "prefixItems": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  }
               ],
               "title": "Merge Window Size",
               "type": "array"
            }
         },
         "required": [
            "out_dim_ratio",
            "merge_window_size"
         ],
         "title": "Swin3DPatchMergingConfig",
         "type": "object"
      },
      "Swin3DPatchSplittingConfig": {
         "properties": {
            "out_dim_ratio": {
               "title": "Out Dim Ratio",
               "type": "integer"
            },
            "final_window_size": {
               "maxItems": 3,
               "minItems": 3,
               "prefixItems": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  }
               ],
               "title": "Final Window Size",
               "type": "array"
            }
         },
         "required": [
            "out_dim_ratio",
            "final_window_size"
         ],
         "title": "Swin3DPatchSplittingConfig",
         "type": "object"
      },
      "Swin3DStageConfig": {
         "properties": {
            "dim": {
               "default": 0,
               "description": "dim at which attention is performed",
               "title": "Dim",
               "type": "integer"
            },
            "mlp_ratio": {
               "default": 4,
               "title": "Mlp Ratio",
               "type": "integer"
            },
            "activation": {
               "default": "gelu",
               "title": "Activation",
               "type": "string"
            },
            "mlp_drop_prob": {
               "default": 0.0,
               "title": "Mlp Drop Prob",
               "type": "number"
            },
            "num_heads": {
               "description": "Number of query heads",
               "title": "Num Heads",
               "type": "integer"
            },
            "ratio_q_to_kv_heads": {
               "default": 1,
               "title": "Ratio Q To Kv Heads",
               "type": "integer"
            },
            "logit_scale_learnable": {
               "default": false,
               "title": "Logit Scale Learnable",
               "type": "boolean"
            },
            "attn_drop_prob": {
               "default": 0.0,
               "title": "Attn Drop Prob",
               "type": "number"
            },
            "proj_drop_prob": {
               "default": 0.0,
               "title": "Proj Drop Prob",
               "type": "number"
            },
            "max_attention_batch_size": {
               "default": -1,
               "description": "Runs attention by splitting the inputs into chunks of this size. 0 means no chunking. Useful for large inputs during inference.",
               "title": "Max Attention Batch Size",
               "type": "integer"
            },
            "norm_location": {
               "default": "post",
               "enum": [
                  "pre",
                  "post"
               ],
               "title": "Norm Location",
               "type": "string"
            },
            "layer_norm_eps": {
               "default": 1e-06,
               "title": "Layer Norm Eps",
               "type": "number"
            },
            "depth": {
               "title": "Depth",
               "type": "integer"
            },
            "window_size": {
               "maxItems": 3,
               "minItems": 3,
               "prefixItems": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  }
               ],
               "title": "Window Size",
               "type": "array"
            },
            "use_relative_position_bias": {
               "default": false,
               "title": "Use Relative Position Bias",
               "type": "boolean"
            },
            "patch_merging": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/Swin3DPatchMergingConfig"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            },
            "patch_splitting": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/Swin3DPatchSplittingConfig"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            },
            "in_dim": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "In Dim"
            },
            "out_dim": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Out Dim"
            }
         },
         "required": [
            "num_heads",
            "depth",
            "window_size"
         ],
         "title": "Swin3DStageConfig",
         "type": "object"
      }
   },
   "required": [
      "dim",
      "in_channels",
      "patch_size",
      "stages"
   ]
}

Config:
  • arbitrary_types_allowed: bool = True

  • extra: str = ignore

  • validate_default: bool = True

  • validate_assignment: bool = True

  • validate_return: bool = True

Fields:
Validators:
field dim: int [Required]#
Validated by:
field in_channels: int [Required]#
Validated by:
field patch_size: tuple[int, int, int] [Required]#
Validated by:
field image_size: tuple[int, int, int] | None = None#

required for learnable absolute position embeddings

Validated by:
field stages: list[Swin3DStageConfig] [Required]#
Validated by:
field drop_prob: float = 0.0#
Validated by:
field embed_spacing_info: bool = False#
Validated by:
field use_absolute_position_embeddings: bool = True#
Validated by:
field learnable_absolute_position_embeddings: bool = False#
Validated by:
populate()[source]#
validator validate  »  all fields[source]#

Base method for validating the model after creation.

pydantic model vision_architectures.nets.swin_3d.Swin3DMIMConfig[source]#

Bases: Swin3DConfig

Show JSON schema
{
   "title": "Swin3DMIMConfig",
   "type": "object",
   "properties": {
      "dim": {
         "title": "Dim",
         "type": "integer"
      },
      "in_channels": {
         "title": "In Channels",
         "type": "integer"
      },
      "patch_size": {
         "maxItems": 3,
         "minItems": 3,
         "prefixItems": [
            {
               "type": "integer"
            },
            {
               "type": "integer"
            },
            {
               "type": "integer"
            }
         ],
         "title": "Patch Size",
         "type": "array"
      },
      "image_size": {
         "anyOf": [
            {
               "maxItems": 3,
               "minItems": 3,
               "prefixItems": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  }
               ],
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "description": "required for learnable absolute position embeddings",
         "title": "Image Size"
      },
      "stages": {
         "items": {
            "$ref": "#/$defs/Swin3DStageConfig"
         },
         "title": "Stages",
         "type": "array"
      },
      "drop_prob": {
         "default": 0.0,
         "title": "Drop Prob",
         "type": "number"
      },
      "embed_spacing_info": {
         "default": false,
         "title": "Embed Spacing Info",
         "type": "boolean"
      },
      "use_absolute_position_embeddings": {
         "default": true,
         "title": "Use Absolute Position Embeddings",
         "type": "boolean"
      },
      "learnable_absolute_position_embeddings": {
         "default": false,
         "title": "Learnable Absolute Position Embeddings",
         "type": "boolean"
      },
      "mim": {
         "additionalProperties": true,
         "title": "Mim",
         "type": "object"
      }
   },
   "$defs": {
      "Swin3DPatchMergingConfig": {
         "properties": {
            "out_dim_ratio": {
               "title": "Out Dim Ratio",
               "type": "integer"
            },
            "merge_window_size": {
               "maxItems": 3,
               "minItems": 3,
               "prefixItems": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  }
               ],
               "title": "Merge Window Size",
               "type": "array"
            }
         },
         "required": [
            "out_dim_ratio",
            "merge_window_size"
         ],
         "title": "Swin3DPatchMergingConfig",
         "type": "object"
      },
      "Swin3DPatchSplittingConfig": {
         "properties": {
            "out_dim_ratio": {
               "title": "Out Dim Ratio",
               "type": "integer"
            },
            "final_window_size": {
               "maxItems": 3,
               "minItems": 3,
               "prefixItems": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  }
               ],
               "title": "Final Window Size",
               "type": "array"
            }
         },
         "required": [
            "out_dim_ratio",
            "final_window_size"
         ],
         "title": "Swin3DPatchSplittingConfig",
         "type": "object"
      },
      "Swin3DStageConfig": {
         "properties": {
            "dim": {
               "default": 0,
               "description": "dim at which attention is performed",
               "title": "Dim",
               "type": "integer"
            },
            "mlp_ratio": {
               "default": 4,
               "title": "Mlp Ratio",
               "type": "integer"
            },
            "activation": {
               "default": "gelu",
               "title": "Activation",
               "type": "string"
            },
            "mlp_drop_prob": {
               "default": 0.0,
               "title": "Mlp Drop Prob",
               "type": "number"
            },
            "num_heads": {
               "description": "Number of query heads",
               "title": "Num Heads",
               "type": "integer"
            },
            "ratio_q_to_kv_heads": {
               "default": 1,
               "title": "Ratio Q To Kv Heads",
               "type": "integer"
            },
            "logit_scale_learnable": {
               "default": false,
               "title": "Logit Scale Learnable",
               "type": "boolean"
            },
            "attn_drop_prob": {
               "default": 0.0,
               "title": "Attn Drop Prob",
               "type": "number"
            },
            "proj_drop_prob": {
               "default": 0.0,
               "title": "Proj Drop Prob",
               "type": "number"
            },
            "max_attention_batch_size": {
               "default": -1,
               "description": "Runs attention by splitting the inputs into chunks of this size. 0 means no chunking. Useful for large inputs during inference.",
               "title": "Max Attention Batch Size",
               "type": "integer"
            },
            "norm_location": {
               "default": "post",
               "enum": [
                  "pre",
                  "post"
               ],
               "title": "Norm Location",
               "type": "string"
            },
            "layer_norm_eps": {
               "default": 1e-06,
               "title": "Layer Norm Eps",
               "type": "number"
            },
            "depth": {
               "title": "Depth",
               "type": "integer"
            },
            "window_size": {
               "maxItems": 3,
               "minItems": 3,
               "prefixItems": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  },
                  {
                     "type": "integer"
                  }
               ],
               "title": "Window Size",
               "type": "array"
            },
            "use_relative_position_bias": {
               "default": false,
               "title": "Use Relative Position Bias",
               "type": "boolean"
            },
            "patch_merging": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/Swin3DPatchMergingConfig"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            },
            "patch_splitting": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/Swin3DPatchSplittingConfig"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            },
            "in_dim": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "In Dim"
            },
            "out_dim": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Out Dim"
            }
         },
         "required": [
            "num_heads",
            "depth",
            "window_size"
         ],
         "title": "Swin3DStageConfig",
         "type": "object"
      }
   },
   "required": [
      "dim",
      "in_channels",
      "patch_size",
      "stages",
      "mim"
   ]
}

Config:
  • arbitrary_types_allowed: bool = True

  • extra: str = ignore

  • validate_default: bool = True

  • validate_assignment: bool = True

  • validate_return: bool = True

Fields:
Validators:

field mim: dict [Required]#
Validated by:
class vision_architectures.nets.swin_3d.Swin3DLayer(config={}, **kwargs)[source]#

Bases: Module

__init__(config={}, **kwargs)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(hidden_states)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class vision_architectures.nets.swin_3d.Swin3DBlock(stage_config)[source]#

Bases: Module

__init__(stage_config)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(hidden_states)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class vision_architectures.nets.swin_3d.Swin3DPatchMerging(merge_window_size, in_dim, out_dim)[source]#

Bases: Module

__init__(merge_window_size, in_dim, out_dim)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(hidden_states)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class vision_architectures.nets.swin_3d.Swin3DStage(stage_config)[source]#

Bases: Module

__init__(stage_config)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(hidden_states)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class vision_architectures.nets.swin_3d.Swin3DEncoder(config)[source]#

Bases: Module, PyTorchModelHubMixin

__init__(config)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(hidden_states)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class vision_architectures.nets.swin_3d.Swin3DModel(config)[source]#

Bases: Module, PyTorchModelHubMixin

__init__(config)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(pixel_values, spacings, mask_patches=None, mask_token=None)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class vision_architectures.nets.swin_3d.Swin3DMIMDecoder(config)[source]#

Bases: Module

__init__(config)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(encodings)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class vision_architectures.nets.swin_3d.Swin3DMIM(config)[source]#

Bases: Module, PyTorchModelHubMixin

__init__(config)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(pixel_values, spacings)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.