code: def test_sample_textures_uv(self):
      barycentric_coords = torch.tensor(
          [[0.5, 0.3, 0.2], [0.3, 0.6, 0.1]], dtype=torch.float32
      ).view(1, 1, 1, 2, -1)
      dummy_verts = torch.zeros(4, 3)
      vert_uvs = torch.tensor(
          [[1, 0], [0, 1], [1, 1], [0, 0]], dtype=torch.float32
      )
      face_uvs = torch.tensor([[0, 1, 2], [1, 2, 3]], dtype=torch.int64)
      interpolated_uvs = torch.tensor(
          [[0.5 + 0.2, 0.3 + 0.2], [0.6, 0.3 + 0.6]],
          dtype=torch.float32,
      )
  
      # Create a dummy texture map
      H = 2
      W = 2
      x = torch.linspace(0, 1, W).view(1, W).expand(H, W)
      y = torch.linspace(0, 1, H).view(H, 1).expand(H, W)
      tex_map = torch.stack([x, y], dim=2).view(1, H, W, 2)
      pix_to_face = torch.tensor([0, 1], dtype=torch.int64).view(
          1, 1, 1, 2
      )
      fragments = Fragments(
          pix_to_face=pix_to_face,
          bary_coords=barycentric_coords,
          zbuf=pix_to_face,
          dists=pix_to_face,
      )
  
      for align_corners in [True, False]:
          tex = TexturesUV(
              maps=tex_map,
              faces_uvs=[face_uvs],
              verts_uvs=[vert_uvs],
              align_corners=align_corners,
          )
          meshes = Meshes(
              verts=[dummy_verts], faces=[face_uvs], textures=tex
          )
          mesh_textures = meshes.textures
          texels = mesh_textures.sample_textures(fragments)
  
          # Expected output
          pixel_uvs = interpolated_uvs * 2.0 - 1.0
          pixel_uvs = pixel_uvs.view(2, 1, 1, 2)
          tex_map_ = torch.flip(tex_map, [1]).permute(0, 3, 1, 2)
          tex_map_ = torch.cat([tex_map_, tex_map_], dim=0)
          expected_out = F.grid_sample(
              tex_map_,
              pixel_uvs,
              align_corners=align_corners,
              padding_mode="border",
          )
          self.assertTrue(
              torch.allclose(texels.squeeze(), expected_out.squeeze())
          )
  
imports: import unittest
  import torch
  import torch.nn.functional
  from pytorch3d.renderer.mesh.rasterizer import Fragments
  from pytorch3d.renderer.mesh.textures import _list_to_padded_wrapper, TexturesAtlas, TexturesUV, TexturesVertex
  from pytorch3d.renderer.mesh.utils import pack_rectangles, pack_unique_rectangles, Rectangle
  from pytorch3d.structures import list_to_packed, Meshes, packed_to_list
  from .common_testing import TestCaseMixin
  from .test_meshes import init_mesh
label_desc: Use image node_id 2 for calling the TestTexturesUV obj's underlying member method code with example usage: obj.test_sample_textures_uv() without return types