code: def generate_rotation_3d(rng, B):
      rotates = []
      for i in range(B):
          alpha = np.pi * (2.0 * rng.rand() - 1.0)
          beta = np.pi / 2.0 * (2.0 * rng.rand() - 1.0)
          gamma = np.pi * (2.0 * rng.rand() - 1.0)
  
          c, s = np.cos(alpha), np.sin(alpha)
          Ra = np.asarray([[c, -s, 0], [s, c, 0], [0, 0, 1]])
          c, s = np.cos(beta), np.sin(beta)
          Rb = np.asarray([[c, 0, s], [0, 1, 0], [-s, 0, c]])
          c, s = np.cos(gamma), np.sin(gamma)
          Rg = np.asarray([[1, 0, 0], [0, c, -s], [0, s, c]])
          rotate = Ra.dot(Rb).dot(Rg)
          rotates.append(rotate)
      return np.asarray(rotates)
  
imports: from __future__ import division
  from six.moves import range
  import itertools
  import numpy
label_desc: Use image node_id 13 for calling a global function with example usage: generate_rotation_3d(rng, B) and returns: np