code: def modify_deep_field(struct, path, new_deep_field, new_struct=None):
      import hail.ir.ir as ir
  
      refs = [struct]
      for i in range(len(path)):
          refs.append(ir.Ref(Env.get_uid(), refs[i].typ[path[i]]))
  
      acc = new_deep_field(refs[-1])
      for parent_struct, field_name in zip(refs[-2::-1], path[::-1]):
          acc = ir.InsertFields(
              parent_struct, [(field_name, acc)], None
          )
      if new_struct is not None:
          acc = new_struct(acc, refs[-1])
      for struct_ref, field_ref, field_name in zip(
          refs[-2::-1], refs[:0:-1], path[::-1]
      ):
          acc = ir.Let(
              field_ref.name, ir.GetField(struct_ref, field_name), acc
          )
      return acc
  
file_path: hail/hail/python/hail/ir/utils.py
imports: from typing import Optional, List, Any, Tuple
  import hail
  from hail.utils.java import Env
  from hail.expr.types import tint32, tint64
label_desc: Use image node_id 4 for calling a global function with example usage: modify_deep_field(struct, path, new_deep_field, new_struct) and returns: acc