code: def solve_translation(p3d, p2d, mvp):
      p3d = torch.from_numpy(p3d.copy()).float()
      p2d = torch.from_numpy(p2d.copy()).float()
      mvp = torch.from_numpy(mvp.copy()).float()
      translation = torch.zeros_like(p3d[0:1, 0:3], requires_grad=True)
      optim_list = [
          {"params": translation, "lr": 1e-3},
      ]
      optim = torch.optim.Adam(optim_list)
  
      total_iters = 1000
      for i in tqdm(range(total_iters), total=total_iters):
          xyzw = torch.cat(
              [p3d[:, 0:3] + translation, torch.ones_like(p3d[:, 0:1])],
              axis=1,
          )
          camera_points = torch.matmul(mvp, xyzw.T).T
          image_points = camera_points / camera_points[:, 2:3]
          image_points = image_points[:, :2]
          optim.zero_grad()
          loss = torch.nn.functional.mse_loss(image_points, p2d)
          loss.backward()
          optim.step()
      print("loss", loss, "translation", translation)
      return translation.clone().detach().cpu().numpy()
  
imports: import sys
  import argparse
  import os
  import copy
  import torch
  import joblib
  import numpy
  import open3d
  import cv2
  from tqdm import tqdm
  from data_io import colmap_helper
  from utils import debug_utils, ray_utils
  from cameras import camera_pose
  from geometry.basics import Translation, Rotation
  from geometry import transformations
label_desc: Use image node_id 4 for calling a global function with example usage: solve_translation(p3d, p2d, mvp) and returns: translation