docstr: Returns the next pending result in order.
  This returns the next result produced by :py:meth:`alibi.utils.distributed.ActorPool.submit`, blocking
  for up to the specified timeout until it is available.
  
  Returns
  -------
  The next result.
  
  Raises
  ------
  TimeoutError
      If the timeout is reached.
  
  Examples
  ---------
  >>> pool = ActorPool(...)
  >>> pool.submit(lambda a, v: a.double.remote(v), 1)
  >>> print(pool.get_next())
  2
code: def get_next(self, timeout=None):
      """
      Returns the next pending result in order.
      This returns the next result produced by :py:meth:`alibi.utils.distributed.ActorPool.submit`, blocking
      for up to the specified timeout until it is available.
  
      Returns
      -------
      The next result.
  
      Raises
      ------
      TimeoutError
          If the timeout is reached.
  
      Examples
      ---------
      >>> pool = ActorPool(...)
      >>> pool.submit(lambda a, v: a.double.remote(v), 1)
      >>> print(pool.get_next())
      2
      """
      if not self.has_next():
          raise StopIteration("No more results to get")
      if self._next_return_index >= self._next_task_index:
          raise ValueError(
              "It is not allowed to call get_next() after "
              "get_next_unordered()."
          )
      future = self._index_to_future[self._next_return_index]
      if timeout is not None:
          res, _ = ray.wait([future], timeout=timeout)
          if not res:
              raise TimeoutError("Timed out waiting for result")
      del self._index_to_future[self._next_return_index]
      self._next_return_index += 1
      i, a = self._future_to_actor.pop(future)
      self._return_actor(a)
      return ray.get(future)
  
imports: import copy
  import logging
  from functools import partial
  from typing import Any, Callable, Dict, Generator, List, Optional, Tuple, Union
  import numpy
  from scipy import sparse
  import ray
label_desc: Use image node_id 6 for calling the ActorPool obj's underlying member method code with example usage: obj.get_next(timeout) and returns: ray