code: def bernoulli(
      prob=None,
      logit=None,
      size=None,
      dtype=None,
      device=None,
      out=None,
  ):
      """Creates a Bernoulli distribution parameterized by :attr:`prob`
      or :attr:`logit` (but not both).
  
      Samples are binary (0 or 1). They take the value `1` with probability `p`
      and `0` with probability `1 - p`.
  
      Parameters
      ----------
      prob : float, ndarray
          The probability of sampling '1'.
          Only one of prob or logit should be passed in.
      logit : float, ndarray
          The log-odds of sampling '1'.
          Only one of prob or logit should be passed in.
      size : int or tuple of ints, optional
          Output shape.  If the given shape is, e.g., ``(m, n, k)``, then
          ``m * n * k`` samples are drawn.  Default is None, in which case a
          single value is returned.
      dtype : dtype, optional
          Desired dtype of the result. All dtypes are determined by their
          name, i.e., 'int64', 'int', etc, so byteorder is not available
          and a specific precision may have different C types depending
          on the platform. The default value is 'np.float32'.
      device : Device, optional
          Device context of output. Default is current device.
      out : symbol, optional
          The output symbol (default is `None`).
  
      Returns
      -------
      out : ndarray
          Drawn samples from the parameterized bernoulli distribution.
  
      Examples
      --------
      >>> prob = np.random.uniform(size=(4,4))
      >>> logit = np.log(prob) - np.log(1 - prob)
      >>> npx.random.bernoulli(logit=logit)
      array([[0., 1., 1., 1.],
          [0., 1., 1., 1.],
          [0., 1., 0., 0.],
          [1., 0., 1., 0.]])
  
      >>> npx.random.bernoulli(prob=prob)
      array([[0., 1., 0., 1.],
          [1., 1., 1., 1.],
          [1., 1., 1., 0.],
          [1., 0., 1., 0.]])
      """
      from ...numpy import ndarray as np_ndarray
  
      tensor_type_name = np_ndarray
      if (prob is None) == (logit is None):
          raise ValueError(
              "Either `prob` or `logit` must be specified, but not both. "
              + "Received prob={}, logit={}".format(prob, logit)
          )
      if dtype is None:
          dtype = "float32"
      if device is None:
          device = current_device()
      if size == ():
          size = None
      if prob is not None:
          is_tensor = isinstance(prob, tensor_type_name)
          if is_tensor:
              return _npi.bernoulli(
                  prob,
                  prob=None,
                  logit=None,
                  is_logit=False,
                  size=size,
                  ctx=device,
                  dtype=dtype,
                  out=out,
              )
          else:
              return _npi.bernoulli(
                  prob=prob,
                  logit=None,
                  is_logit=False,
                  size=size,
                  ctx=device,
                  dtype=dtype,
                  out=out,
              )
      else:
          is_tensor = isinstance(logit, tensor_type_name)
          if is_tensor:
              return _npi.bernoulli(
                  logit,
                  prob=None,
                  logit=None,
                  is_logit=True,
                  size=size,
                  ctx=device,
                  dtype=dtype,
                  out=out,
              )
          else:
              return _npi.bernoulli(
                  prob=None,
                  logit=logit,
                  is_logit=True,
                  size=size,
                  ctx=device,
                  dtype=dtype,
                  out=out,
              )
  
imports: from ...device import current_device
  from ..numpy import _internal
  from ...util import wrap_ctx_to_device_func
label_desc: Use image node_id 1 for calling a global function with example usage: bernoulli(prob, logit, size, dtype, device, out) and returns: _npi, _npi, _npi, _npi