> This page is for version 0.5.0 · 26.06.
> For other versions, use one of these documentation indexes:
> - Nightly (default): https://docs.nvidia.com/nemo/automodel/nightly/llms.txt
> - Latest: https://docs.nvidia.com/nemo/automodel/latest/llms.txt
> - 0.7.0 · 26.10: https://docs.nvidia.com/nemo/automodel/v0.7/llms.txt
> - 0.5.0 · 26.06: https://docs.nvidia.com/nemo/automodel/v0.5/llms.txt
> - 0.4.0 · 26.04: https://docs.nvidia.com/nemo/automodel/v0.4/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/nemo/automodel/llms.txt.

# nemo_automodel.components.datasets.decision.gs1

Native GS1 training lines as single-question SystemOne records.

A native line is `&#123;"request": &#123;"state", "questions", optional "id"&#125;, "targets": &#123;question_id: &#123;"candidate_ids",
"distribution"&#125;&#125;&#125;`. Its request is a SystemOne request, so a record keeps the state and question unchanged and adds
the target distribution as `soft_labels`. Reading a record is the model's business (the GS1 decision reader); this
module only converts and validates the data.

## Module Contents

### Functions

| Name                                                                                    | Description                                                                            |
| --------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| [`contains_media`](#nemo_automodel-components-datasets-decision-gs1-contains_media)     | Whether a request state holds image or video blocks (top-level list items).            |
| [`convert_gs1_line`](#nemo_automodel-components-datasets-decision-gs1-convert_gs1_line) | Convert one native GS1 training line into validated single-question SystemOne records. |

### Data

[`MAX_CANDIDATES`](#nemo_automodel-components-datasets-decision-gs1-MAX_CANDIDATES)

### API

```python
nemo_automodel.components.datasets.decision.gs1.contains_media(
    state: typing.Any
) -> bool
```

Whether a request state holds image or video blocks (top-level list items).

**Parameters:**

**`state`** `Any`

The `state` of a request.

---

**Returns:** `bool`

`True` for a list state with an `&#123;"type": "image"&#125;` or `&#123;"type": "video"&#125;` item.

```python
nemo_automodel.components.datasets.decision.gs1.convert_gs1_line(
    line: dict[str, typing.Any],
    number: int = 0
) -> list[dict[str, typing.Any]]
```

Convert one native GS1 training line into validated single-question SystemOne records.

**Parameters:**

**`line`** `dict[str, Any]`

A native line (see the module docstring).

---

**`number`** `int` — default: 0

Line number, used for the record IDs when the request has no `id`.

---

**Returns:** `list[dict[str, Any]]`

One record per question, with ID `"&lt;request id&gt;/&lt;question id&gt;"`: the request's state and that question, its

**Raises:**

* `ValueError`: If the state is null (not a GS1 request), a record is not a valid SystemOne record, the targets do
  not name exactly the request's questions and each question's candidates, or a distribution is not finite,
  nonnegative and normalized.

```python
nemo_automodel.components.datasets.decision.gs1.MAX_CANDIDATES = 255
```