class_docstr: 'ShapeNetBase' implements a base Dataset for ShapeNet and R2N2 with helper methods.
  It is not intended to be used on its own as a Dataset for a Dataloader. Both __init__
  and __getitem__ need to be implemented.
class_docstr_tok: ["'ShapeNetBase","'","implements","a","base","Dataset","for","ShapeNet","and","R2N2","with","helper","methods",".","It","is","not","intended","to","be","used","on","its","own","as","a","Dataset","for","a","Dataloader",".","Both","__init__","and","__getitem__","need","to","be","implemented","."]
docstr: Helper function for converting user provided model_ids, categories and sample_nums
  to indices of models in the loaded dataset. If model idxs are provided, we check if
  the idxs are valid. If no models are specified, the first model in the loaded dataset
  is chosen. The function returns the file paths to the selected models.
  
  Args:
      model_ids: List[str] of model_ids of models to be rendered.
      categories: List[str] of categories to be rendered.
      sample_nums: List[int] of number of models to be randomly sampled from
          each category.
      idxs: List[int] of indices of models to be rendered in the dataset.
  
  Returns:
      List of paths of models to be rendered.
docstr_tok: ["Helper","function","for","converting","user","provided","model_ids",",","categories","and","sample_nums","to","indices","of","models","in","the","loaded","dataset",".","If","model","idxs","are","provided",",","we","check","if","the","idxs","are","valid",".","If","no","models","are","specified",",","the","first","model","in","the","loaded","dataset","is","chosen",".","The","function","returns","the","file","paths","to","the","selected","models",".","Args",":","model_ids",":","List","[","str","]","of","model_ids","of","models","to","be","rendered",".","categories",":","List","[","str","]","of","categories","to","be","rendered",".","sample_nums",":","List","[","int","]","of","number","of","models","to","be","randomly","sampled","from","each","category",".","idxs",":","List","[","int","]","of","indices","of","models","to","be","rendered","in","the","dataset",".","Returns",":","List","of","paths","of","models","to","be","rendered","."]
code: def _handle_render_inputs(
      self,
      model_ids: Optional[List[str]] = None,
      categories: Optional[List[str]] = None,
      sample_nums: Optional[List[int]] = None,
      idxs: Optional[List[int]] = None,
  ) -> List[int]:
      """
      Helper function for converting user provided model_ids, categories and sample_nums
      to indices of models in the loaded dataset. If model idxs are provided, we check if
      the idxs are valid. If no models are specified, the first model in the loaded dataset
      is chosen. The function returns the file paths to the selected models.
  
      Args:
          model_ids: List[str] of model_ids of models to be rendered.
          categories: List[str] of categories to be rendered.
          sample_nums: List[int] of number of models to be randomly sampled from
              each category.
          idxs: List[int] of indices of models to be rendered in the dataset.
  
      Returns:
          List of paths of models to be rendered.
      """
      # Get corresponding indices if model_ids are supplied.
      if model_ids is not None and len(model_ids) > 0:
          idxs = []
          for model_id in model_ids:
              if model_id not in self.model_ids:
                  raise ValueError(
                      "model_id %s not found in the loaded dataset."
                      % model_id
                  )
              idxs.append(self.model_ids.index(model_id))
  
      # Sample random models if categories and sample_nums are supplied and get
      # the corresponding indices.
      elif categories is not None and len(categories) > 0:
          sample_nums = [1] if sample_nums is None else sample_nums
          if (
              len(categories) != len(sample_nums)
              and len(sample_nums) != 1
          ):
              raise ValueError(
                  "categories and sample_nums needs to be of the same length or "
                  "sample_nums needs to be of length 1."
              )
  
          idxs_tensor = torch.empty(0, dtype=torch.int32)
          for i in range(len(categories)):
              category = self.synset_inv.get(
                  categories[i], categories[i]
              )
              if category not in self.synset_inv.values():
                  raise ValueError(
                      "Category %s is not in the loaded dataset."
                      % category
                  )
              # Broadcast if sample_nums has length of 1.
              sample_num = (
                  sample_nums[i]
                  if len(sample_nums) > 1
                  else sample_nums[0]
              )
              sampled_idxs = self._sample_idxs_from_category(
                  sample_num=sample_num, category=category
              )
              # pyre-fixme[6]: For 1st param expected `Union[List[Tensor],
              #  typing.Tuple[Tensor, ...]]` but got `Tuple[Tensor, List[int]]`.
              idxs_tensor = torch.cat((idxs_tensor, sampled_idxs))
          idxs = idxs_tensor.tolist()
      # Check if the indices are valid if idxs are supplied.
      elif idxs is not None and len(idxs) > 0:
          if any(idx < 0 or idx >= len(self.model_ids) for idx in idxs):
              raise IndexError(
                  "One or more idx values are out of bounds. Indices need to be"
                  "between 0 and %s." % (len(self.model_ids) - 1)
              )
      # Check if sample_nums is specified, if so sample sample_nums[0] number
      # of indices from the entire loaded dataset. Otherwise randomly select one
      # index from the dataset.
      else:
          sample_nums = [1] if sample_nums is None else sample_nums
          if len(sample_nums) > 1:
              msg = (
                  "More than one sample sizes specified, now sampling "
                  "%d models from the dataset." % sample_nums[0]
              )
              warnings.warn(msg)
          idxs = self._sample_idxs_from_category(sample_nums[0])
      return idxs
  
file_path: pytorch3d/pytorch3d/datasets/shapenet_base.py
imports: import warnings
  from typing import Dict, List, Optional, Tuple
  import torch
  from pytorch3d.common.datatypes import Device
  from pytorch3d.io import load_obj
  from pytorch3d.renderer import FoVPerspectiveCameras, HardPhongShader, MeshRasterizer, MeshRenderer, PointLights, RasterizationSettings, TexturesVertex
  from .utils import collate_batched_meshes
label_desc: Use image node_id 7 for calling the ShapeNetBase obj's underlying member method code with example usage: obj._handle_render_inputs(model_ids, categories, sample_nums, idxs) and returns: idxs