# tfma.utils.get_by_keys

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/model-analysis/blob/v0.46.0/tensorflow_model_analysis/utils/util.py#L426-L492) |

Returns value with given key(s) in (possibly multi-level) dict.

    tfma.utils.get_by_keys(
        data: Mapping[str, Any],
        keys: Sequence[Any],
        default_value=None,
        optional: bool = False
    ) -> Any

The keys represent multiple levels of indirection into the data. For example
if 3 keys are passed then the data is expected to be a dict of dict of dict.
For compatibily with data that uses prefixing to create separate the keys in a
single dict, lookups will also be searched for under the keys separated by
'/'. For example, the keys 'head1' and 'probabilities' could be stored in a
a single dict as 'head1/probabilties'.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `data` | Dict to get value from. |
| `keys` | Sequence of keys to lookup in data. None keys will be ignored. |
| `default_value` | Default value if not found. |
| `optional` | Whether the key is optional or not. If default value is None and optional is False then a ValueError will be raised if key not found. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If (non-optional) key is not found. |

<br />