docstr: Confirm that torch.multinomial does not sample elements which have
  zero probability.
docstr_tok: ["Confirm","that","torch.multinomial","does","not","sample","elements","which","have","zero","probability","."]
code: def test_multinomial(self):
      """
      Confirm that torch.multinomial does not sample elements which have
      zero probability.
      """
      freqs = torch.cuda.FloatTensor(
          [
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.03178183361887932,
              0.027680952101945877,
              0.033176131546497345,
              0.046052902936935425,
              0.07742464542388916,
              0.11543981730937958,
              0.14148041605949402,
              0.15784293413162231,
              0.13180233538150787,
              0.08271478116512299,
              0.049702685326337814,
              0.027557924389839172,
              0.018125897273421288,
              0.011851548217236996,
              0.010252203792333603,
              0.007422595750540495,
              0.005372154992073774,
              0.0045109698548913,
              0.0036087757907807827,
              0.0035267581697553396,
              0.0018864056328311563,
              0.0024605290964245796,
              0.0022964938543736935,
              0.0018453967059031129,
              0.0010662291897460818,
              0.0009842115687206388,
              0.00045109697384759784,
              0.0007791675161570311,
              0.00020504408166743815,
              0.00020504408166743815,
              0.00020504408166743815,
              0.00012302644609007984,
              0.0,
              0.00012302644609007984,
              4.100881778867915e-05,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
              0.0,
          ]
      )
  
      sample = []
      for _ in range(1000):
          torch.cuda.get_rng_state()
          sample = torch.multinomial(freqs, 1000, True)
          if freqs[sample].min() == 0:
              sample_idx = (freqs[sample] == 0).nonzero()[0][0]
              sampled = sample[sample_idx]
              print(
                  "%s th element of last sample was %s, which has probability %s"
                  % (sample_idx, sampled, freqs[sampled])
              )
              return False
      return True
  
imports: import unittest
  import numpy
  import torch
  from PIL import Image
  from pytorch3d.io import load_objs_as_meshes
  from pytorch3d.ops import sample_points_from_meshes
  from pytorch3d.renderer import TexturesVertex
  from pytorch3d.renderer.cameras import FoVPerspectiveCameras, look_at_view_transform
  from pytorch3d.renderer.mesh.rasterize_meshes import barycentric_coordinates
  from pytorch3d.renderer.points import NormWeightedCompositor, PointsRasterizationSettings, PointsRasterizer, PointsRenderer
  from pytorch3d.structures import Meshes, Pointclouds
  from pytorch3d.utils.ico_sphere import ico_sphere
  from .common_testing import get_pytorch3d_dir, get_random_cuda_device, get_tests_dir, TestCaseMixin
label_desc: Use image node_id 4 for calling the TestSamplePoints obj's underlying member method code with example usage: obj.test_multinomial() and returns: True, False