code: def prune_empty(nest):
      """Prune empty nests from a nest.
  
      Parameters
      ----------
      nest
          nest to prune.
  
      Returns
      -------
          pruned nest with all empty nests removed
      """
      valid = False
      if isinstance(nest, dict):
          keys = list(nest)
          for k in keys:
              nest[k] = prune_empty(nest[k])
              if nest[k] is not None:
                  valid = True
          for k in keys:
              if nest[k] is None:
                  del nest[k]
      elif isinstance(nest, (list, tuple)):
          nest = list(nest)
          for i in range(len(nest)):
              nest[i] = prune_empty(nest[i])
              if nest[i] is not None:
                  valid = True
          for i in range(len(nest) - 1, -1, -1):
              if nest[i] is None:
                  del nest[i]
      if (
          not valid
          and not ivy.is_array(nest)
          and not isinstance(nest, (int, float, str))
      ):
          return None
      return nest
  
imports: from builtins import map
  from typing import Callable, Any, Union, List, Tuple, Optional, Dict, Iterable, Sequence
  from collections import UserDict, OrderedDict
  import ivy
  from ivy.utils.exceptions import handle_exceptions
label_desc: Use image node_id 19 for calling a global function with example usage: prune_empty(nest) and returns: nest, None