code: def testMapStructureUpTo(self):
      ab_tuple = collections.namedtuple("ab_tuple", "a, b")
      op_tuple = collections.namedtuple("op_tuple", "add, mul")
      inp_val = ab_tuple(a=2, b=3)
      inp_ops = ab_tuple(
          a=op_tuple(add=1, mul=2), b=op_tuple(add=2, mul=3)
      )
      out = nest.map_structure_up_to(
          inp_val,
          lambda val, ops: (val + ops.add) * ops.mul,
          inp_val,
          inp_ops,
      )
      self.assertEqual(out.a, 6)
      self.assertEqual(out.b, 15)
  
      data_list = ((2, 4, 6, 8), ((1, 3, 5, 7, 9), (3, 5, 7)))
      name_list = ("evens", ("odds", "primes"))
      out = nest.map_structure_up_to(
          name_list,
          lambda name, sec: "first_{}_{}".format(len(sec), name),
          name_list,
          data_list,
      )
      self.assertEqual(
          out, ("first_4_evens", ("first_5_odds", "first_3_primes"))
      )
  
imports: import collections
  import dataclasses
  from absl.testing import parameterized
  import numpy
  from tensorflow.python.data.kernel_tests import test_base
  from tensorflow.python.data.util import nest
  from tensorflow.python.framework import combinations
  from tensorflow.python.framework import constant_op
  from tensorflow.python.framework import sparse_tensor
  from tensorflow.python.framework import tensor
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops.ragged import ragged_factory_ops
  from tensorflow.python.platform import test
label_desc: Use image node_id 18 for calling the NestTest obj's underlying member method code with example usage: obj.testMapStructureUpTo() without return types