code: def _single_map_nested(args):
      """Apply a function recursively to each element of a nested data struct."""
      function, data_struct, types, rank, disable_tqdm, desc = args
  
      # Singleton first to spare some computation
      if not isinstance(data_struct, dict) and not isinstance(
          data_struct, types
      ):
          return function(data_struct)
  
      # Reduce logging to keep things readable in multiprocessing with tqdm
      if rank is not None and logging.get_verbosity() < logging.WARNING:
          logging.set_verbosity_warning()
      # Print at least one thing to fix tqdm in notebooks in multiprocessing
      # see https://github.com/tqdm/tqdm/issues/485#issuecomment-473338308
      if (
          rank is not None
          and not disable_tqdm
          and any(
              "notebook" in tqdm_cls.__name__
              for tqdm_cls in tqdm.__mro__
          )
      ):
          print(" ", end="", flush=True)
  
      # Loop over single examples or batches and write to buffer/file if examples are to be updated
      pbar_iterable = (
          data_struct.items()
          if isinstance(data_struct, dict)
          else data_struct
      )
      pbar_desc = (
          (desc + " " if desc is not None else "") + "#" + str(rank)
          if rank is not None
          else desc
      )
      with hf_tqdm(
          pbar_iterable,
          disable=disable_tqdm,
          position=rank,
          unit="obj",
          desc=pbar_desc,
      ) as pbar:
          if isinstance(data_struct, dict):
              return {
                  k: _single_map_nested(
                      (function, v, types, None, True, None)
                  )
                  for k, v in pbar
              }
          else:
              mapped = [
                  _single_map_nested(
                      (function, v, types, None, True, None)
                  )
                  for v in pbar
              ]
              if isinstance(data_struct, list):
                  return mapped
              elif isinstance(data_struct, tuple):
                  return tuple(mapped)
              else:
                  return np.array(mapped)
  
imports: import copy
  import functools
  import itertools
  import multiprocessing.pool
  import os
  import queue
  import re
  import types
  import warnings
  from contextlib import contextmanager
  from dataclasses import fields, is_dataclass
  from multiprocessing import Manager
  from queue import Empty
  from shutil import disk_usage
  from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple, TypeVar, Union
  from urllib.parse import urlparse
  import multiprocess
  import multiprocess.pool
  import numpy
  from tqdm.auto import tqdm
  from ..None import config
  from ..parallel import parallel_map
  from .None import logging
  from .None import tqdm
  from ._dill import Pickler, dump, dumps, pklregister
label_desc: Use image node_id 12 for calling a global function with example usage: _single_map_nested(args) and returns: function, unknown, mapped, tuple, np