docstr: Test that streaming datasets return the correct number of batches, and that
  the length is also calculated correctly.
docstr_tok: ["Test","that","streaming","datasets","return","the","correct","number","of","batches",",","and","that","the","length","is","also","calculated","correctly","."]
code: def test_dataset_async(self):
      """
      Test that streaming datasets return the correct number of batches, and that
      the length is also calculated correctly.
      """
  
      NUM_SAMPLES = 1024
      dataset = ZeroImageDataset(
          crop_size=224,
          num_channels=3,
          num_classes=1000,
          num_samples=NUM_SAMPLES,
      )
  
      base_dataloader = DataLoader(
          dataset=dataset, pin_memory=True, num_workers=20
      )
      dataloader = DataloaderAsyncGPUWrapper(base_dataloader)
  
      # Test wrap correctness
      i = 0
      for sample in dataloader:
          # test that the data being served is all zeros
          self.assertTrue(
              sample["input"].nonzero(as_tuple=False).numel() == 0
          )
  
          # test that it's all cuda tensors
          for k in sample.keys():
              self.assertTrue(sample[k].device.type == "cuda")
  
          # check that consecutive samples are independent objects in memory
          sample["input"].fill_(3.14)
  
          # check that the expected number of samples is served
          i += 1
      self.assertEqual(i, NUM_SAMPLES)
  
file_path: ClassyVision/test/dataloader_async_gpu_wrapper_test.py
imports: import unittest
  import numpy
  import torch
  import torchvision.transforms
  from classy_vision.dataset.dataloader_async_gpu_wrapper import DataloaderAsyncGPUWrapper
  from PIL import Image
  from torch.utils.data import DataLoader, Dataset
label_desc: Use image node_id 1 for calling the TestDataloaderAsyncGPUWrapper obj's underlying member method code with example usage: obj.test_dataset_async() without return types