> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ag2.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# autogen.import_utils.optional_import_block

<code class="doc-symbol doc-symbol-heading doc-symbol-function" />

#### optional\_import\_block

```python theme={null}
optional_import_block() -> Generator[Result, None, None]
```

Guard a block of code to suppress ImportErrors

A context manager to temporarily suppress ImportErrors.<br />Use this to attempt imports without failing immediately on missing modules.<br />Example:

```python theme={null}
with optional_import_block(): <br/>    import some_module
    import some_other_module
```

<br />
