code: def _elem_to_numpy_eager(
      tf_el: TensorflowElem,
  ) -> Union[NumpyElem, Iterable[NumpyElem]]:
      """Converts a single element from tf to numpy."""
      if isinstance(tf_el, tf.Tensor):
          return (
              tf_el._numpy()
          )  # pytype: disable=attribute-error  # pylint: disable=protected-access
      elif isinstance(tf_el, tf.RaggedTensor):
          return tf_el
      elif isinstance(tf_el, tf.data.Dataset):
          return _IterableDataset(_eager_dataset_iterator, tf_el)
      elif tf_el is None:
          return None
      else:
          raise AssertionError(
              f"Unexpected element: {type(tf_el)}: {tf_el}"
          )
  
imports: from __future__ import annotations
  import collections.abc
  import functools
  import typing
  from typing import Any, Callable, Iterable, Iterator, Union
  from etils import enp
  from etils.etree import nest
  import numpy
  from tensorflow_datasets.core import logging
  from tensorflow_datasets.core import utils
  from tensorflow_datasets.core.utils import tree_utils
  from tensorflow_datasets.core.utils import type_utils
  from tensorflow_datasets.core.utils.lazy_imports_utils import tensorflow
label_desc: Use image node_id 4 for calling a global function with example usage: _elem_to_numpy_eager(tf_el) and returns: tf_el, tf_el, _IterableDataset, None