code: def _nested_map(condition, fn, condition_msg=None):
      def _map(obj):
          if condition(obj):
              return fn(obj)
          elif obj is None:
              return None
          elif isinstance(obj, (list, tuple)):
              mapped = (_map(x) for x in obj)
              if hasattr(obj, "_fields"):
                  # obj is namedtuple
                  return type(obj)(*mapped)
              return type(obj)(mapped)
          elif isinstance(obj, dict):
              return {x: _map(obj[x]) for x in obj}
          else:
              raise ValueError(
                  "Auto nesting doesn't know how to process "
                  "an input object of type "
                  + torch.typename(obj)
                  + (
                      ". Accepted types: "
                      + condition_msg
                      + ", or lists/tuples of them"
                      if condition_msg
                      else ""
                  )
              )
  
      return _map
  
imports: import functools
  import inspect
  import itertools
  import warnings
  from collections import OrderedDict
  from typing import Any, List, Optional, Tuple
  import torch
  import torch._C
  import torch._functorch
  import torch.utils.hooks
  from torch._C import _functions
  from torch._functorch.autograd_function import custom_function_call
label_desc: Use image node_id 3 for calling a global function with example usage: _nested_map(condition, fn, condition_msg) and returns: _map, fn, None, type, type, unknown