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: If a list of model_ids are supplied, render all the objects by the given model_ids.
  If no model_ids are supplied, but categories and sample_nums are specified, randomly
  select a number of objects (number specified in sample_nums) in the given categories
  and render these objects. If instead a list of idxs is specified, check if the idxs
  are all valid and render models by the given idxs. Otherwise, randomly select a number
  (first number in sample_nums, default is set to be 1) of models from the loaded dataset
  and render these models.
  
  Args:
      model_ids: List[str] of model_ids of models intended to be rendered.
      categories: List[str] of categories intended to be rendered. categories
          and sample_nums must be specified at the same time. categories can be given
          in the form of synset offsets or labels, or a combination of both.
      sample_nums: List[int] of number of models to be randomly sampled from
          each category. Could also contain one single integer, in which case it
          will be broadcasted for every category.
      idxs: List[int] of indices of models to be rendered in the dataset.
      shader_type: Select shading. Valid options include HardPhongShader (default),
          SoftPhongShader, HardGouraudShader, SoftGouraudShader, HardFlatShader,
          SoftSilhouetteShader.
      device: Device (as str or torch.device) on which the tensors should be located.
      **kwargs: Accepts any of the kwargs that the renderer supports.
  
  Returns:
      Batch of rendered images of shape (N, H, W, 3).
docstr_tok: ["If","a","list","of","model_ids","are","supplied",",","render","all","the","objects","by","the","given","model_ids",".","If","no","model_ids","are","supplied",",","but","categories","and","sample_nums","are","specified",",","randomly","select","a","number","of","objects","(","number","specified","in","sample_nums",")","in","the","given","categories","and","render","these","objects",".","If","instead","a","list","of","idxs","is","specified",",","check","if","the","idxs","are","all","valid","and","render","models","by","the","given","idxs",".","Otherwise",",","randomly","select","a","number","(","first","number","in","sample_nums",",","default","is","set","to","be","1",")","of","models","from","the","loaded","dataset","and","render","these","models",".","Args",":","model_ids",":","List","[","str","]","of","model_ids","of","models","intended","to","be","rendered",".","categories",":","List","[","str","]","of","categories","intended","to","be","rendered",".","categories","and","sample_nums","must","be","specified","at","the","same","time",".","categories","can","be","given","in","the","form","of","synset","offsets","or","labels",",","or","a","combination","of","both",".","sample_nums",":","List","[","int","]","of","number","of","models","to","be","randomly","sampled","from","each","category",".","Could","also","contain","one","single","integer",",","in","which","case","it","will","be","broadcasted","for","every","category",".","idxs",":","List","[","int","]","of","indices","of","models","to","be","rendered","in","the","dataset",".","shader_type",":","Select","shading",".","Valid","options","include","HardPhongShader","(","default",")",",","SoftPhongShader",",","HardGouraudShader",",","SoftGouraudShader",",","HardFlatShader",",","SoftSilhouetteShader",".","device",":","Device","(","as","str","or","torch.device",")","on","which","the","tensors","should","be","located",".","*","*","kwargs",":","Accepts","any","of","the","kwargs","that","the","renderer","supports",".","Returns",":","Batch","of","rendered","images","of","shape","(","N",",","H",",","W",",","3",")","."]
code: def render(
      self,
      model_ids: Optional[List[str]] = None,
      categories: Optional[List[str]] = None,
      sample_nums: Optional[List[int]] = None,
      idxs: Optional[List[int]] = None,
      shader_type=HardPhongShader,
      device: Device = "cpu",
      **kwargs,
  ) -> torch.Tensor:
      """
      If a list of model_ids are supplied, render all the objects by the given model_ids.
      If no model_ids are supplied, but categories and sample_nums are specified, randomly
      select a number of objects (number specified in sample_nums) in the given categories
      and render these objects. If instead a list of idxs is specified, check if the idxs
      are all valid and render models by the given idxs. Otherwise, randomly select a number
      (first number in sample_nums, default is set to be 1) of models from the loaded dataset
      and render these models.
  
      Args:
          model_ids: List[str] of model_ids of models intended to be rendered.
          categories: List[str] of categories intended to be rendered. categories
              and sample_nums must be specified at the same time. categories can be given
              in the form of synset offsets or labels, or a combination of both.
          sample_nums: List[int] of number of models to be randomly sampled from
              each category. Could also contain one single integer, in which case it
              will be broadcasted for every category.
          idxs: List[int] of indices of models to be rendered in the dataset.
          shader_type: Select shading. Valid options include HardPhongShader (default),
              SoftPhongShader, HardGouraudShader, SoftGouraudShader, HardFlatShader,
              SoftSilhouetteShader.
          device: Device (as str or torch.device) on which the tensors should be located.
          **kwargs: Accepts any of the kwargs that the renderer supports.
  
      Returns:
          Batch of rendered images of shape (N, H, W, 3).
      """
      idxs = self._handle_render_inputs(
          model_ids, categories, sample_nums, idxs
      )
      # Use the getitem method which loads mesh + texture
      models = [self[idx] for idx in idxs]
      meshes = collate_batched_meshes(models)["mesh"]
      if meshes.textures is None:
          meshes.textures = TexturesVertex(
              verts_features=torch.ones_like(
                  meshes.verts_padded(), device=device
              )
          )
  
      meshes = meshes.to(device)
      cameras = kwargs.get("cameras", FoVPerspectiveCameras()).to(
          device
      )
      if len(cameras) != 1 and len(cameras) % len(meshes) != 0:
          raise ValueError(
              "Mismatch between batch dims of cameras and meshes."
          )
      if len(cameras) > 1:
          # When rendering R2N2 models, if more than one views are provided, broadcast
          # the meshes so that each mesh can be rendered for each of the views.
          meshes = meshes.extend(len(cameras) // len(meshes))
      renderer = MeshRenderer(
          rasterizer=MeshRasterizer(
              cameras=cameras,
              raster_settings=kwargs.get(
                  "raster_settings", RasterizationSettings()
              ),
          ),
          shader=shader_type(
              device=device,
              cameras=cameras,
              lights=kwargs.get("lights", PointLights()).to(device),
          ),
      )
      return renderer(meshes)
  
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 6 for calling the ShapeNetBase obj's underlying member method code with example usage: obj.render(model_ids, categories, sample_nums, idxs, shader_type, device) and returns: renderer