code: def write(self):
      if os.path.isfile(self.outputfile):
          with open(self.outputfile, "r") as file:
              input_data = file.read()
              outputdict = json.loads(input_data)
      else:
          outputdict = []
  
      outputimagedict = {"image": self.filename, "annotations": []}
  
      for shape in self.shapes:
          points = shape["points"]
  
          x1 = points[0][0]
          y1 = points[0][1]
          x2 = points[1][0]
          y2 = points[2][1]
  
          height, width, x, y = self.calculate_coordinates(
              x1, x2, y1, y2
          )
  
          shapedict = {
              "label": shape["label"],
              "coordinates": {
                  "x": x,
                  "y": y,
                  "width": width,
                  "height": height,
              },
          }
          outputimagedict["annotations"].append(shapedict)
  
      # check if image already in output
      exists = False
      for i in range(0, len(outputdict)):
          if outputdict[i]["image"] == outputimagedict["image"]:
              exists = True
              outputdict[i] = outputimagedict
              break
  
      if not exists:
          outputdict.append(outputimagedict)
  
      Path(self.outputfile).write_text(
          json.dumps(outputdict), ENCODE_METHOD
      )
  
file_path: PaddleOCR/PPOCRLabel/libs/create_ml_io.py
imports: import json
  from pathlib import Path
  from libs.constants import DEFAULT_ENCODING
  import os
label_desc: Use image node_id 2 for calling the CreateMLWriter obj's underlying member method code with example usage: obj.write() without return types