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 sampling a number of indices from the given category.
  
  Args:
      sample_num: number of indices to be sampled from the given category.
      category: category synset of the category to be sampled from. If not
          specified, sample from all models in the loaded dataset.
docstr_tok: ["Helper","function","for","sampling","a","number","of","indices","from","the","given","category",".","Args",":","sample_num",":","number","of","indices","to","be","sampled","from","the","given","category",".","category",":","category","synset","of","the","category","to","be","sampled","from",".","If","not","specified",",","sample","from","all","models","in","the","loaded","dataset","."]
code: def _sample_idxs_from_category(
      self, sample_num: int = 1, category: Optional[str] = None
  ) -> List[int]:
      """
      Helper function for sampling a number of indices from the given category.
  
      Args:
          sample_num: number of indices to be sampled from the given category.
          category: category synset of the category to be sampled from. If not
              specified, sample from all models in the loaded dataset.
      """
      start = (
          self.synset_start_idxs[category]
          if category is not None
          else 0
      )
      range_len = (
          self.synset_num_models[category]
          if category is not None
          else self.__len__()
      )
      replacement = sample_num > range_len
      sampled_idxs = (
          torch.multinomial(
              torch.ones((range_len), dtype=torch.float32),
              sample_num,
              replacement=replacement,
          )
          + start
      )
      if replacement:
          msg = (
              "Sample size %d is larger than the number of objects in %s, "
              "values sampled with replacement."
          ) % (
              sample_num,
              "category " + category
              if category is not None
              else "all categories",
          )
          warnings.warn(msg)
      # pyre-fixme[7]: Expected `List[int]` but got `Tensor`.
      return sampled_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 8 for calling the ShapeNetBase obj's underlying member method code with example usage: obj._sample_idxs_from_category(sample_num, category) and returns: sampled_idxs