code: def map_tree_up_to(shallow, fn, tree, *rest):
      """`map_tree` with recursion depth defined by depth of `shallow`."""
      return nest.map_structure_up_to(shallow, fn, tree, *rest)
  
imports: import functools
  import numpy
  import six
  import tensorflow.compat.v2
  from tensorflow.python.util import nest
label_desc: Use image node_id 4 for calling a global function with example usage: map_tree_up_to(shallow, fn, tree) and returns: nest