code: def sample(self, size=1):
          
          samples = scipy.stats.bernoulli.rvs(self.p, size=size)
          if size == 1:
              return samples[0]
          return samples
docs: Generate samples of the random variable.
  
          Parameters
          ----------
          size : int
              The number of samples to generate.
  
          Returns
          -------
          :obj:`numpy.ndarray` of int or int
              The samples of the random variable. If `size == 1`, then
              the returned value will not be wrapped in an array.