# `ExTorch.JIT`

TorchScript model loading, inference, and management.

This module provides functions to load pre-trained TorchScript (`.pt`) models,
run inference, inspect model structure, and manage model lifecycle.

## Example

    model = ExTorch.JIT.load("model.pt")
    input = ExTorch.randn({1, 3, 224, 224})
    output = ExTorch.JIT.forward(model, [input])

# `buffers`

```elixir
@spec buffers(ExTorch.JIT.Model.t()) :: [{String.t(), ExTorch.Tensor.t()}]
```

Get named buffers of a model.

## Returns
A list of `{name, tensor}` tuples.

# `eval`

```elixir
@spec eval(ExTorch.JIT.Model.t()) :: :ok
```

Set a model to evaluation mode.

# `forward`

```elixir
@spec forward(ExTorch.JIT.Model.t(), [ExTorch.Tensor.t()]) :: term()
```

Run the forward method on a model.

## Arguments
  - `model`: The loaded model.
  - `inputs`: A list of input tensors.

## Returns
The model output, which can be a tensor, tuple, list, map, or scalar
depending on the model's return type.

## Examples

    input = ExTorch.randn({1, 784})
    output = ExTorch.JIT.forward(model, [input])

# `invoke`

```elixir
@spec invoke(ExTorch.JIT.Model.t(), String.t(), [ExTorch.Tensor.t()]) :: term()
```

Invoke a named method on a model.

## Arguments
  - `model`: The loaded model.
  - `method_name`: Name of the method to invoke.
  - `inputs`: A list of input tensors.

## Returns
The method output.

# `load`

```elixir
@spec load(
  String.t(),
  keyword()
) :: ExTorch.JIT.Model.t()
```

Load a TorchScript model from a file.

## Arguments
  - `path`: Path to the `.pt` file.
  - `opts`: Keyword list of options.
    - `:device` - Device to load the model onto (default: `:cpu`).

## Returns
A `%ExTorch.JIT.Model{}` struct.

## Examples

    model = ExTorch.JIT.load("model.pt")
    model = ExTorch.JIT.load("model.pt", device: {:cuda, 0})

# `methods`

```elixir
@spec methods(ExTorch.JIT.Model.t()) :: [String.t()]
```

Get the names of all methods on a model.

## Returns
A list of method name strings.

# `modules`

```elixir
@spec modules(ExTorch.JIT.Model.t()) :: [String.t()]
```

Get names of submodules of a model.

## Returns
A list of submodule name strings.

# `parameters`

```elixir
@spec parameters(ExTorch.JIT.Model.t()) :: [{String.t(), ExTorch.Tensor.t()}]
```

Get named parameters of a model.

## Returns
A list of `{name, tensor}` tuples.

# `save`

```elixir
@spec save(ExTorch.JIT.Model.t(), String.t()) :: :ok
```

Save a TorchScript model to a file.

## Arguments
  - `model`: The model to save.
  - `path`: Path to save the `.pt` file.

# `to`

```elixir
@spec to(ExTorch.JIT.Model.t(), ExTorch.Device.device()) :: ExTorch.JIT.Model.t()
```

Move a model to a different device.

## Arguments
  - `model`: The model to move.
  - `device`: Target device (e.g., `:cpu`, `{:cuda, 0}`).

## Returns
A new `%ExTorch.JIT.Model{}` on the target device.

# `train`

```elixir
@spec train(ExTorch.JIT.Model.t()) :: :ok
```

Set a model to training mode.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
