class_docstr: Masking distribution for orderless nade training.
class_docstr_tok: ["Masking","distribution","for","orderless","nade","training","."]
docstr: Sample a mask.
  
  Args:
    shape: shape of pianoroll (time, pitch, instrument)
    separate_instruments: whether instruments are separated
  
  Returns:
    A mask of shape `shape`.
docstr_tok: ["Sample","a","mask",".","Args",":","shape",":","shape","of","pianoroll","(","time",",","pitch",",","instrument",")","separate_instruments",":","whether","instruments","are","separated","Returns",":","A","mask","of","shape","`","shape","`","."]
code: def __call__(self, shape, separate_instruments=True, **unused_kwargs):
      """Sample a mask.
  
      Args:
        shape: shape of pianoroll (time, pitch, instrument)
        separate_instruments: whether instruments are separated
  
      Returns:
        A mask of shape `shape`.
      """
      tt, pp, ii = shape
  
      if separate_instruments:
          d = tt * ii
      else:
          assert ii == 1
          d = tt * pp
      # sample a mask size
      k = np.random.choice(d) + 1
      # sample a mask of size k
      i = np.random.choice(d, size=k, replace=False)
  
      mask = np.zeros(d, dtype=np.float32)
      mask[i] = 1.0
      if separate_instruments:
          mask = mask.reshape((tt, 1, ii))
          mask = np.tile(mask, [1, pp, 1])
      else:
          mask = mask.reshape((tt, pp, 1))
      return mask
  
file_path: magenta/magenta/models/coconet/lib_mask.py
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from magenta.models.coconet import lib_util
  import numpy
label_desc: Use image node_id 1 for calling the OrderlessMaskoutMethod obj's underlying member method code with example usage: obj.__call__(shape, separate_instruments) and returns: mask