code: def nested_reduce(ds, f):
      new_d = {}
      for k, v in ds[0].items():
          if isinstance(v, dict):
              new_d[k] = nested_reduce([d[k] for d in ds], f)
          else:
              new_d[k] = f([d[k] for d in ds])
      return new_d
  
imports: import json
  import os
  import re
  import shutil
  import uuid
  from dataclasses import dataclass, field
  from typing import Callable, Optional, Set, List, Dict
  import blobfile
  import numpy
  import torch
  from mpi4py import MPI
  import summarize_from_feedback
  from summarize_from_feedback.model_layout import ModelLayout
  from summarize_from_feedback.models import sample_fns
  from summarize_from_feedback.models.loss_functions import softmax_xent_loss_fn
  from summarize_from_feedback.models.transformer import Hyperparams
  from summarize_from_feedback.models.transformer import build_with_random_weights
  from summarize_from_feedback.utils import exact_div, hyperparams
  from summarize_from_feedback.utils import blobs
  from summarize_from_feedback.utils.dist_utils import setup_cuda_device_and_dist, create_data_parallel_comm, create_within_replica_comm
  from summarize_from_feedback.utils.nested import map_nested
  from summarize_from_feedback.utils.torch_utils import nans, to_numpy
label_desc: Use image node_id 10 for calling a global function with example usage: nested_reduce(ds, f) and returns: new_d