docstr: Compare output of vectorized single directional chamfer loss with naive implementation
  for point_reduction = "sum" and batch_reduction = None.
docstr_tok: ["Compare","output","of","vectorized","single","directional","chamfer","loss","with","naive","implementation","for","point_reduction","=","``","sum","''","and","batch_reduction","=","None","."]
code: def test_single_directional_chamfer_point_reduction_sum(self):
      """
      Compare output of vectorized single directional chamfer loss with naive implementation
      for point_reduction = "sum" and batch_reduction = None.
      """
      N, P1, P2 = 7, 10, 18
      device = get_random_cuda_device()
      points_normals = TestChamfer.init_pointclouds(N, P1, P2, device)
      p1 = points_normals.p1
      p2 = points_normals.p2
      p1_normals = points_normals.n1
      p2_normals = points_normals.n2
      weights = points_normals.weights
      p11 = p1.detach().clone()
      p22 = p2.detach().clone()
      p11.requires_grad = True
      p22.requires_grad = True
  
      pred_loss, pred_loss_norm = TestChamfer.chamfer_distance_naive(
          p1, p2, x_normals=p1_normals, y_normals=p2_normals
      )
  
      loss, loss_norm = chamfer_distance(
          p11,
          p22,
          x_normals=p1_normals,
          y_normals=p2_normals,
          weights=weights,
          batch_reduction=None,
          point_reduction="sum",
          single_directional=True,
      )
      pred_loss_sum = pred_loss[0].sum(1)
      pred_loss_sum *= weights
      self.assertClose(loss, pred_loss_sum)
  
      pred_loss_norm_sum = pred_loss_norm[0].sum(1)
      pred_loss_norm_sum *= weights
      self.assertClose(loss_norm, pred_loss_norm_sum)
  
      # Check gradients
      self._check_gradients(
          loss,
          loss_norm,
          pred_loss_sum,
          pred_loss_norm_sum,
          p1,
          p11,
          p2,
          p22,
      )
  
imports: import unittest
  from collections import namedtuple
  import numpy
  import torch
  import torch.nn.functional
  from pytorch3d.loss import chamfer_distance
  from pytorch3d.structures.pointclouds import Pointclouds
  from .common_testing import get_random_cuda_device, TestCaseMixin
label_desc: Use image node_id 13 for calling the TestChamfer obj's underlying member method code with example usage: obj.test_single_directional_chamfer_point_reduction_sum() without return types