parameters: (face_vertices, unit=False)
return_statement: return face_normals
docstring: r"""Calculate normals of triangle meshes.
  
          Args:
              face_vertices (torch.Tensor):
                  of shape :math:`(\text{batch_size}, \text{num_faces}, 3, 3)`.
              unit (bool):
                  if true, return normals as unit vectors. Default: False.
          Returns:
              (torch.FloatTensor):
                  face normals, of shape :math:`(\text{batch_size}, \text{num_faces}, 3)`
docstring_summary: r"""Calculate normals of triangle meshes.
docstring_tokens: r Calculate normals of triangle meshes .
function: def face_normals(face_vertices, unit=False):
      r"""Calculate normals of triangle meshes.
  
          Args:
              face_vertices (torch.Tensor):
                  of shape :math:`(\text{batch_size}, \text{num_faces}, 3, 3)`.
              unit (bool):
                  if true, return normals as unit vectors. Default: False.
          Returns:
              (torch.FloatTensor):
                  face normals, of shape :math:`(\text{batch_size}, \text{num_faces}, 3)`
          """
      if face_vertices.shape[-2] != 3:
          raise NotImplementedError("face_normals is only implemented for triangle meshes")
      # Note: Here instead of using the normals from vertexlist2facelist we compute it from scratch
      edges_dist0 = face_vertices[:, :, 1] - face_vertices[:, :, 0]
      edges_dist1 = face_vertices[:, :, 2] - face_vertices[:, :, 0]
      face_normals = torch.cross(edges_dist0, edges_dist1, dim=2)
  
      if unit:
          face_normals_length = face_normals.norm(dim=2, keepdim=True)
          face_normals = face_normals / (face_normals_length + 1e-10)
  
      return face_normals
function_tokens: def face_normals ( face_vertices , unit = False ) : if face_vertices . shape [ - 2 ] != 3 : raise NotImplementedError ( "face_normals is only implemented for triangle meshes" ) # Note: Here instead of using the normals from vertexlist2facelist we compute it from scratch edges_dist0 = face_vertices [ : , : , 1 ] - face_vertices [ : , : , 0 ] edges_dist1 = face_vertices [ : , : , 2 ] - face_vertices [ : , : , 0 ] face_normals = torch . cross ( edges_dist0 , edges_dist1 , dim = 2 ) if unit : face_normals_length = face_normals . norm ( dim = 2 , keepdim = True ) face_normals = face_normals / ( face_normals_length + 1e-10 ) return face_normals