code: def coerce_real(vals: np.ndarray, limit=0.0001):
      """Return a copy of the array with only the real numbers, with a check.
  
      If any of the imaginary part of a value is greater than the provided limit,
      then assert an error.
  
      Args:
        vals: The array to convert
        limit: The limit above which any imaginary part of a value causes an error.
  
      Returns:
        The array with only the real portions of the numbers.
      """
      assert np.all(
          np.imag(vals) < limit
      ), "Array contains imaginary part out of acceptable limits."
      return np.real(vals)
  
imports: from collections.abc import Callable, Collection, Iterable, Iterator, Mapping, Sequence
  import itertools
  import queue
  import threading
  import time
  from typing import Any, Optional, TypeVar, Union
  import uuid
  from lit_nlp.api import types
  import numpy
label_desc: Use image node_id 16 for calling a global function with example usage: coerce_real(vals, limit) and returns: np