code: def get_num_samples(targets, num_classes, dtype=None):
      batch_size = targets.size(0)
      with torch.no_grad():
          ones = torch.ones_like(targets, dtype=dtype)
          num_samples = ones.new_zeros((batch_size, num_classes))
          num_samples.scatter_add_(1, targets, ones)
      return num_samples
  
imports: import torch
  import torch.nn.functional
label_desc: Use image node_id 1 for calling a global function with example usage: get_num_samples(targets, num_classes, dtype) and returns: num_samples