code: def _format_faces_indices(
      faces_indices, max_index: int, device, pad_value=None
  ):
      """
      Format indices and check for invalid values. Indices can refer to
      values in one of the face properties: vertices, textures or normals.
      See comments of the load_obj function for more details.
  
      Args:
          faces_indices: List of ints of indices.
          max_index: Max index for the face property.
          pad_value: if any of the face_indices are padded, specify
              the value of the padding (e.g. -1). This is only used
              for texture indices indices where there might
              not be texture information for all the faces.
  
      Returns:
          faces_indices: List of ints of indices.
  
      Raises:
          ValueError if indices are not in a valid range.
      """
      faces_indices = _make_tensor(
          faces_indices, cols=3, dtype=torch.int64, device=device
      )
  
      if pad_value is not None:
          mask = faces_indices.eq(pad_value).all(dim=-1)
  
      # Change to 0 based indexing.
      faces_indices[(faces_indices > 0)] -= 1
  
      # Negative indexing counts from the end.
      faces_indices[(faces_indices < 0)] += max_index
  
      if pad_value is not None:
          # pyre-fixme[61]: `mask` is undefined, or not always defined.
          faces_indices[mask] = pad_value
  
      return _check_faces_indices(faces_indices, max_index, pad_value)
  
imports: import os
  import warnings
  from collections import namedtuple
  from pathlib import Path
  from typing import List, Optional
  import numpy
  import torch
  from iopath.common.file_io import PathManager
  from PIL import Image
  from pytorch3d.common.datatypes import Device
  from pytorch3d.io.mtl_io import load_mtl, make_mesh_texture_atlas
  from pytorch3d.io.utils import _check_faces_indices, _make_tensor, _open_file, PathOrStr
  from pytorch3d.renderer import TexturesAtlas, TexturesUV
  from pytorch3d.structures import join_meshes_as_batch, Meshes
  from .pluggable_formats import endswith, MeshFormatInterpreter
label_desc: Use image node_id 1 for calling a global function with example usage: _format_faces_indices(faces_indices, max_index, device, pad_value) and returns: _check_faces_indices