code: def update_text_dict_dim(t, dim, update_node=False):
      """
      Update text box <t>'s dimensions and set its width to dim[0] and height to dim[1].
      If <update_node> is True, also set the respective attributes in the respective XML node of the text box.
      """
      if len(dim) != 2:
          raise ValueError(
              "text box dimensions `dim` must be sequence of length 2"
          )
  
      t_w, t_h = dim
      t_right = t["left"] + t_w
      t_bottom = t["top"] + t_h
  
      t.update(
          {
              "width": t_w,
              "height": t_h,
              "bottom": t_bottom,
              "right": t_right,
              "bottomleft": np.array((t["left"], t_bottom)),
              "topright": np.array((t_right, t["top"])),
              "bottomright": np.array((t_right, t_bottom)),
          }
      )
  
      if update_node:
          update_text_xmlnode(t, "width", t_w)
          update_text_xmlnode(t, "height", t_h)
  
imports: import xml.etree.ElementTree
  from collections import OrderedDict
  import json
  import struct
  import imghdr
  import numpy
  from .geom import pt, rect
label_desc: Use image node_id 8 for calling a global function with example usage: update_text_dict_dim(t, dim, update_node) without return types