# `ExTorch.Index`

An index is an object that can act as an accessor to a ``ExTorch.Tensor``.
ExTorch has five kinds of indices:

# `actual_index`

```elixir
@type actual_index() ::
  nil
  | boolean()
  | ExTorch.Index.Slice.t()
  | integer()
  | ExTorch.Tensor.t()
  | :ellipsis
```

An actual index element, after aliases are interpreted.

# `dim_modifier_index`

```elixir
@type dim_modifier_index() :: nil | boolean()
```

Dimension appending/removing indices.

## Description
- `nil` - Adds an empty dimension on the specified position.
- `true` - Same as `nil`
- `false` - Adds a zero dimension on the specified position.

# `ellipsis_index`

```elixir
@type ellipsis_index() :: :ellipsis | :...
```

Skip dimensions in between other ones.

# Notes
Ellipsis indices will behave as a sequence of empty
`ExTorch.Index.Slice`s between the dimensions that are specified.
e.g.,

```elixir
a = ExTorch.empty({3, 4, 5, 6})

# Indexing will yield a tensor of size {4, 5}
indexing = ExTorch.index(a, [0, :..., 1])
```

# `index`

```elixir
@type index() ::
  dim_modifier_index()
  | range_index()
  | tensor_list_index()
  | ellipsis_index()
  | integer_index()
```

An individual index element.

# `integer_index`

```elixir
@type integer_index() :: integer()
```

Access a tensor given a particular integer index.

# `integer_list`

```elixir
@type integer_list() :: integer_index() | [integer_list()]
```

# `range_index`

```elixir
@type range_index() :: Range.t() | ExTorch.Index.Slice.t() | :&quot;::&quot;
```

Access a slice of elements in the tensor given a range.

## Description
- `start..end//step` - A standard Elixir range struct, it will be non-inclusive
   on `end`, as opposed to its usual behaviour in Elixir.
- `Slice.t()` - See `ExTorch.Index.Slice`
- `:::` - Same as invoking `ExTorch.slice/0`.

# `t`

```elixir
@type t() :: index() | [index()] | tuple()
```

A complete possible index. It can be either a puntual index or a list of puntual indices.

# `tensor_list_index`

```elixir
@type tensor_list_index() :: ExTorch.Tensor.t() | integer_list()
```

Access a tensor given another tensor or a list of integers.

---

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