class_docstr: Utility class for recursing over nested iterables
docstr: Iterate over the nested list, applying:
  * ``f_map`` (T -> U) to items
  * ``f_reduce`` (Iterable[U] -> U) to mapped items
  
  For instance, ``map_reduce([[1, 2], 3, 4])`` is::
  
      f_reduce([
        f_reduce([
          f_map(1),
          f_map(2)
        ]),
        f_map(3),
        f_map(4)
      ]])
  
  
  State can be passed down through the calls with `f_kwargs`,
  to iterables of mapped items. When kwargs are passed, as in
  ``map_reduce([[1, 2], 3, 4], **kw)``, this becomes::
  
      kw1 = f_kwargs(**kw)
      kw2 = f_kwargs(**kw1)
      f_reduce([
        f_reduce([
          f_map(1), **kw2)
          f_map(2,  **kw2)
        ],      **kw1),
        f_map(3, **kw1),
        f_map(4, **kw1)
      ]],     **kw)
code: def map_reduce(
      self,
      x,
      f_map=lambda x, **kwargs: x,
      f_reduce=lambda x, **kwargs: x,
      f_kwargs=lambda **kwargs: kwargs,
      **kwargs,
  ):
      """
      Iterate over the nested list, applying:
      * ``f_map`` (T -> U) to items
      * ``f_reduce`` (Iterable[U] -> U) to mapped items
  
      For instance, ``map_reduce([[1, 2], 3, 4])`` is::
  
          f_reduce([
            f_reduce([
              f_map(1),
              f_map(2)
            ]),
            f_map(3),
            f_map(4)
          ]])
  
  
      State can be passed down through the calls with `f_kwargs`,
      to iterables of mapped items. When kwargs are passed, as in
      ``map_reduce([[1, 2], 3, 4], **kw)``, this becomes::
  
          kw1 = f_kwargs(**kw)
          kw2 = f_kwargs(**kw1)
          f_reduce([
            f_reduce([
              f_map(1), **kw2)
              f_map(2,  **kw2)
            ],      **kw1),
            f_map(3, **kw1),
            f_map(4, **kw1)
          ]],     **kw)
      """
  
      def f(x, **kwargs):
          if not self.recurse_if(x):
              return f_map(x, **kwargs)
          else:
              next_kwargs = f_kwargs(**kwargs)
              return f_reduce(
                  (f(xi, **next_kwargs) for xi in x), **kwargs
              )
  
      return f(x, **kwargs)
  
file_path: dask/dask/array/numpy_compat.py
imports: from __future__ import annotations
  import warnings
  import numpy
  from packaging.version import parse
  from dask.utils import derived_from
label_desc: Use image node_id 2 for calling the _Recurser obj's underlying member method code with example usage: obj.map_reduce(x, f_map, f_reduce, f_kwargs) and returns: f, f_map, f_reduce