code: def test_weighted_perspective_n_points(
      self, batch_size=16, num_pts=200
  ):
      # instantiate random x_world and y
      y = torch.randn((batch_size, num_pts, 2)).cuda() / 3.0
      (
          x_cam,
          x_world,
          R,
          T,
      ) = TestPerspectiveNPoints._generate_epnp_test_from_2d(y)
  
      # randomly drop 50% of the rows
      weights = (torch.rand_like(x_world[:, :, 0]) > 0.5).float()
  
      # make sure we retain at least 6 points for each case
      weights[:, :6] = 1.0
  
      # fill ignored y with trash to ensure that we get different
      # solution in case the weighting is wrong
      y = y + (1 - weights[:, :, None]) * 100.0
  
      def norm_fn(t):
          return t.norm(dim=-1)
  
      for skip_quadratic_eq in (True, False):
          # get the solution for the 0/1 weighted case
          sol = perspective_n_points.efficient_pnp(
              x_world,
              y,
              skip_quadratic_eq=skip_quadratic_eq,
              weights=weights,
          )
          sol_R_quat = rotation_conversions.matrix_to_quaternion(sol.R)
          sol_T = sol.T
  
          # check that running only on points with non-zero weights ends in the
          # same place as running the 0/1 weighted version
          for i in range(batch_size):
              ok = weights[i] > 0
              x_world_ok = x_world[i, ok][None]
              y_ok = y[i, ok][None]
              sol_ok = perspective_n_points.efficient_pnp(
                  x_world_ok, y_ok, skip_quadratic_eq=False
              )
              R_est_quat_ok = rotation_conversions.matrix_to_quaternion(
                  sol_ok.R
              )
  
              self.assertNormsClose(
                  sol_T[i], sol_ok.T[0], rtol=3e-3, norm_fn=norm_fn
              )
              self.assertNormsClose(
                  sol_R_quat[i],
                  R_est_quat_ok[0],
                  rtol=3e-4,
                  norm_fn=norm_fn,
              )
  
file_path: pytorch3d/tests/test_perspective_n_points.py
imports: import unittest
  import torch
  from pytorch3d.ops import perspective_n_points
  from pytorch3d.transforms import rotation_conversions
  from .common_testing import TestCaseMixin
label_desc: Use image node_id 7 for calling the TestPerspectiveNPoints obj's underlying member method code with example usage: obj.test_weighted_perspective_n_points(batch_size, num_pts) and returns: t