code: def _save_points3D_txt(self, output_file):
      num_valid_points3D = sum(
          1
          for point3D_idx in self.point3D_id_to_point3D_idx.values()
          if point3D_idx != SceneManager.INVALID_POINT3D
      )
  
      array_to_string = lambda arr: " ".join(str(x) for x in arr)
  
      iter_point3D_id_to_point3D_idx = (
          self.point3D_id_to_point3D_idx.items()
      )
  
      with open(output_file, "w") as fid:
          print(
              "# 3D point list with one line of data per point:",
              file=fid,
          )
          print(
              "#   POINT3D_ID, X, Y, Z, R, G, B, ERROR, TRACK[] as ",
              file=fid,
          )
          print("# (IMAGE_ID, POINT2D_IDX)", file=fid)
          print(
              "# Number of points: {},".format(num_valid_points3D),
              file=fid,
          )
          print("# mean track length: unknown", file=fid)
  
          for point3D_id, point3D_idx in iter_point3D_id_to_point3D_idx:
              if point3D_idx == SceneManager.INVALID_POINT3D:
                  continue
  
              print(point3D_id, file=fid)
              print(
                  array_to_string(self.points3D[point3D_idx]), file=fid
              )
              print(
                  array_to_string(self.point3D_colors[point3D_idx]),
                  file=fid,
              )
              print(self.point3D_errors[point3D_idx], file=fid)
              print(
                  array_to_string(
                      self.point3D_id_to_images[point3D_id].flat
                  ),
                  file=fid,
              )
  
imports: from collections import OrderedDict, defaultdict
  from io import StringIO
  from itertools import combinations
  import os
  import struct
  from .camera import Camera
  from .image import Image
  import numpy
  from .rotation import Quaternion
label_desc: Use image node_id 22 for calling the SceneManager obj's underlying member method code with example usage: obj._save_points3D_txt(output_file) without return types