parameters: (tet_vertices, tetrahedrons_mean=None, pow=4)
return_statement: return equivolume_loss
docstring: r"""Compute the EquiVolume loss as devised by *Gao et al.* in `Learning Deformable Tetrahedral Meshes for 3D
      Reconstruction <https://nv-tlabs.github.io/DefTet/>`_ NeurIPS 2020.
      See `supplementary material <https://nv-tlabs.github.io/DefTet/files/supplement.pdf>`_ for the definition of the loss function.
  
      Args:
          tet_vertices (torch.Tensor):
              Batched tetrahedrons, of shape
              :math:`(\text{batch_size}, \text{num_tetrahedrons}, 4, 3)`.
          tetrahedrons_mean (torch.Tensor):
              Mean volume of all tetrahedrons in a grid,
              of shape :math:`(\text{batch_size})` or :math:`(1,)` (broadcasting).
              Default: Compute ``torch.mean(tet_vertices, dim=-1)``.
          pow (int):
              Power for the equivolume loss.
              Increasing power puts more emphasis on the larger tetrahedron deformation.
              Default: 4.
  
      Returns:
          (torch.Tensor):
              EquiVolume loss for each mesh, of shape :math:`(\text{batch_size})`.
  
      Example:
          >>> tet_vertices = torch.tensor([[[[0.5000, 0.5000, 0.7500],
          ...                                [0.4500, 0.8000, 0.6000],
          ...                                [0.4750, 0.4500, 0.2500],
          ...                                [0.5000, 0.3000, 0.3000]],
          ...                               [[0.4750, 0.4500, 0.2500],
          ...                                [0.5000, 0.9000, 0.3000],
          ...                                [0.4500, 0.4000, 0.9000],
          ...                                [0.4500, 0.4500, 0.7000]]],
          ...                              [[[0.7000, 0.3000, 0.4500],
          ...                                [0.4800, 0.2000, 0.3000],
          ...                                [0.9000, 0.4500, 0.4500],
          ...                                [0.2000, 0.5000, 0.1000]],
          ...                               [[0.3750, 0.4500, 0.2500],
          ...                                [0.9000, 0.8000, 0.7000],
          ...                                [0.6000, 0.9000, 0.3000],
          ...                                [0.5500, 0.3500, 0.9000]]]])
          >>> equivolume(tet_vertices, pow=4)
          tensor([[2.2961e-10],
                  [7.7704e-10]])
docstring_summary: r"""Compute the EquiVolume loss as devised by *Gao et al.* in `Learning Deformable Tetrahedral Meshes for 3D
      Reconstruction <https://nv-tlabs.github.io/DefTet/>`_ NeurIPS 2020.
      See `supplementary material <https://nv-tlabs.github.io/DefTet/files/supplement.pdf>`_ for the definition of the loss function.
docstring_tokens: r Compute the EquiVolume loss as devised by * Gao et al . * in Learning Deformable Tetrahedral Meshes for 3D Reconstruction <https : // nv - tlabs . github . io / DefTet / > _ NeurIPS 2020 . See supplementary material <https : // nv - tlabs . github . io / DefTet / files / supplement . pdf > _ for the definition of the loss function .
function: def equivolume(tet_vertices, tetrahedrons_mean=None, pow=4):
      r"""Compute the EquiVolume loss as devised by *Gao et al.* in `Learning Deformable Tetrahedral Meshes for 3D
      Reconstruction <https://nv-tlabs.github.io/DefTet/>`_ NeurIPS 2020.
      See `supplementary material <https://nv-tlabs.github.io/DefTet/files/supplement.pdf>`_ for the definition of the loss function.
  
      Args:
          tet_vertices (torch.Tensor):
              Batched tetrahedrons, of shape
              :math:`(\text{batch_size}, \text{num_tetrahedrons}, 4, 3)`.
          tetrahedrons_mean (torch.Tensor):
              Mean volume of all tetrahedrons in a grid,
              of shape :math:`(\text{batch_size})` or :math:`(1,)` (broadcasting).
              Default: Compute ``torch.mean(tet_vertices, dim=-1)``.
          pow (int):
              Power for the equivolume loss.
              Increasing power puts more emphasis on the larger tetrahedron deformation.
              Default: 4.
  
      Returns:
          (torch.Tensor):
              EquiVolume loss for each mesh, of shape :math:`(\text{batch_size})`.
  
      Example:
          >>> tet_vertices = torch.tensor([[[[0.5000, 0.5000, 0.7500],
          ...                                [0.4500, 0.8000, 0.6000],
          ...                                [0.4750, 0.4500, 0.2500],
          ...                                [0.5000, 0.3000, 0.3000]],
          ...                               [[0.4750, 0.4500, 0.2500],
          ...                                [0.5000, 0.9000, 0.3000],
          ...                                [0.4500, 0.4000, 0.9000],
          ...                                [0.4500, 0.4500, 0.7000]]],
          ...                              [[[0.7000, 0.3000, 0.4500],
          ...                                [0.4800, 0.2000, 0.3000],
          ...                                [0.9000, 0.4500, 0.4500],
          ...                                [0.2000, 0.5000, 0.1000]],
          ...                               [[0.3750, 0.4500, 0.2500],
          ...                                [0.9000, 0.8000, 0.7000],
          ...                                [0.6000, 0.9000, 0.3000],
          ...                                [0.5500, 0.3500, 0.9000]]]])
          >>> equivolume(tet_vertices, pow=4)
          tensor([[2.2961e-10],
                  [7.7704e-10]])
      """
      _validate_tet_vertices(tet_vertices)
  
      # compute the volume of each tetrahedron
      volumes = tetrahedron_volume(tet_vertices)
  
      if tetrahedrons_mean is None:
          # finding the mean volume of all tetrahedrons in the tetrahedron grid
          tetrahedrons_mean = torch.mean(volumes, dim=-1)
      tetrahedrons_mean = tetrahedrons_mean.reshape(1, -1)
      # compute EquiVolume loss
      equivolume_loss = torch.mean(torch.pow(
          torch.abs(volumes - tetrahedrons_mean), exponent=pow),
          dim=-1, keepdim=True)
  
      return equivolume_loss
function_tokens: def equivolume ( tet_vertices , tetrahedrons_mean = None , pow = 4 ) : _validate_tet_vertices ( tet_vertices ) # compute the volume of each tetrahedron volumes = tetrahedron_volume ( tet_vertices ) if tetrahedrons_mean is None : # finding the mean volume of all tetrahedrons in the tetrahedron grid tetrahedrons_mean = torch . mean ( volumes , dim = - 1 ) tetrahedrons_mean = tetrahedrons_mean . reshape ( 1 , - 1 ) # compute EquiVolume loss equivolume_loss = torch . mean ( torch . pow ( torch . abs ( volumes - tetrahedrons_mean ) , exponent = pow ) , dim = - 1 , keepdim = True ) return equivolume_loss