> 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.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/nemo/automodel/_mcp/server.

# nemo_automodel.components.utils.yaml_utils

## Module Contents

### Functions

| Name                                                                                                           | Description                                                              |
| -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------ |
| [`_enum_representer`](#nemo_automodel-components-utils-yaml_utils-_enum_representer)                           | Represent enums in YAML.                                                 |
| [`_function_representer`](#nemo_automodel-components-utils-yaml_utils-_function_representer)                   | Represent functions in YAML.                                             |
| [`_generation_config_representer`](#nemo_automodel-components-utils-yaml_utils-_generation_config_representer) | Represent transformers GenerationConfig objects in YAML.                 |
| [`_partial_representer`](#nemo_automodel-components-utils-yaml_utils-_partial_representer)                     | Represent functools.partial objects in YAML.                             |
| [`_safe_object_representer`](#nemo_automodel-components-utils-yaml_utils-_safe_object_representer)             | General object representer for YAML.                                     |
| [`_torch_dtype_representer`](#nemo_automodel-components-utils-yaml_utils-_torch_dtype_representer)             | Represent torch dtypes in YAML.                                          |
| [`safe_yaml_representers`](#nemo_automodel-components-utils-yaml_utils-safe_yaml_representers)                 | Context manager for safely adding and removing custom YAML representers. |

### API

```python
nemo_automodel.components.utils.yaml_utils._enum_representer(
    dumper,
    data
)
```

Represent enums in YAML.

```python
nemo_automodel.components.utils.yaml_utils._function_representer(
    dumper,
    data
)
```

Represent functions in YAML.

```python
nemo_automodel.components.utils.yaml_utils._generation_config_representer(
    dumper,
    data
)
```

Represent transformers GenerationConfig objects in YAML.

```python
nemo_automodel.components.utils.yaml_utils._partial_representer(
    dumper,
    data
)
```

Represent functools.partial objects in YAML.

```python
nemo_automodel.components.utils.yaml_utils._safe_object_representer(
    dumper,
    data
)
```

General object representer for YAML.

This function is a fallback for objects that don't have specific representers.
If the object has **qualname** attr,
the *target* is set to f"\{inspect.getmodule(obj).**name**}.\{obj.**qualname**}".
If the object does not have a **qualname** attr, the *target* is set from its **class** attr.
The *call* key is used to indicate whether the target should be called to create an instance.

**Parameters:**

The YAML dumper to use for serialization.

The data to serialize.

**Returns:**

The YAML representation of the data.

```python
nemo_automodel.components.utils.yaml_utils._torch_dtype_representer(
    dumper,
    data
)
```

Represent torch dtypes in YAML.

```python
nemo_automodel.components.utils.yaml_utils.safe_yaml_representers() -> collections.abc.Generator[None, None, None]
```

Context manager for safely adding and removing custom YAML representers.

Temporarily adds custom representers for functions, classes, and other objects
to the YAML SafeDumper, and restores the original representers when exiting
the context.