docstr: Naive implementation of vert_align.
docstr_tok: ["Naive","implementation","of","vert_align","."]
code: def vert_align_naive(
      feats,
      verts,
      return_packed: bool = False,
      align_corners: bool = True,
  ):
      """
      Naive implementation of vert_align.
      """
      if torch.is_tensor(feats):
          feats = [feats]
      N = feats[0].shape[0]
  
      out_feats = []
      # sample every example in the batch separately
      for i in range(N):
          out_i_feats = []
          for feat in feats:
              feats_i = feat[i][None, :, :, :]  # (1, C, H, W)
              if torch.is_tensor(verts):
                  grid = verts[i][None, None, :, :2]  # (1, 1, V, 2)
              elif hasattr(verts, "verts_list"):
                  grid = verts.verts_list()[i][
                      None, None, :, :2
                  ]  # (1, 1, V, 2)
              elif hasattr(verts, "points_list"):
                  grid = verts.points_list()[i][
                      None, None, :, :2
                  ]  # (1, 1, V, 2)
              else:
                  raise ValueError("verts_or_meshes is invalid")
              feat_sampled_i = F.grid_sample(
                  feats_i,
                  grid,
                  mode="bilinear",
                  padding_mode="zeros",
                  align_corners=align_corners,
              )  # (1, C, 1, V)
              feat_sampled_i = feat_sampled_i.squeeze(2).squeeze(
                  0
              )  # (C, V)
              feat_sampled_i = feat_sampled_i.transpose(1, 0)  # (V, C)
              out_i_feats.append(feat_sampled_i)
          out_i_feats = torch.cat(out_i_feats, 1)  # (V, sum(C))
          out_feats.append(out_i_feats)
  
      if return_packed:
          out_feats = torch.cat(out_feats, 0)  # (sum(V), sum(C))
      else:
          out_feats = torch.stack(out_feats, 0)  # (N, V, sum(C))
      return out_feats
  
file_path: pytorch3d/tests/test_vert_align.py
imports: import unittest
  import torch
  import torch.nn.functional
  from pytorch3d.ops.vert_align import vert_align
  from pytorch3d.structures.meshes import Meshes
  from pytorch3d.structures.pointclouds import Pointclouds
  from .common_testing import TestCaseMixin
label_desc: Use image node_id 1 for calling the TestVertAlign obj's underlying member method code with example usage: obj.vert_align_naive(feats, verts, return_packed, align_corners) and returns: out_feats