class_docstr: Negative sampling loss layer.
  
  This link wraps the :func:`~chainer.functions.negative_sampling` function.
  It holds the weight matrix as a parameter. It also builds a sampler
  internally given a list of word counts.
  
  Args:
      in_size (int): Dimension of input vectors.
      counts (int list): Number of each identifiers.
      sample_size (int): Number of negative samples.
      power (float): Power factor :math:`\alpha`.
      dtype (numpy.dtype): Type to use in computing.
  
  .. seealso:: :func:`~chainer.functions.negative_sampling` for more detail.
  
  Attributes:
      W (~chainer.Variable): Weight parameter matrix.
code: def __init__(
      self, in_size, counts, sample_size, power=0.75, dtype=None
  ):
      super(NegativeSampling, self).__init__()
      dtype = chainer.get_dtype(dtype)
      vocab_size = len(counts)
      self.sample_size = sample_size
      power = dtype.type(power)
      p = numpy.array(counts, dtype)
      numpy.power(p, power, p)
      self.sampler = walker_alias.WalkerAlias(p)
  
      with self.init_scope():
          self.W = variable.Parameter(0, (vocab_size, in_size))
  
file_path: chainer/chainer/links/loss/negative_sampling.py
imports: import numpy
  import chainer
  from chainer.functions.loss import negative_sampling
  from chainer import link
  from chainer.utils import argument
  from chainer.utils import walker_alias
  from chainer import variable
label_desc: Use image node_id 1 to create a new NegativeSampling object from inherited base classes: link with example: obj = NegativeSampling(in_size, counts, sample_size, power, dtype)