def mock_raw_image(x_dim=1024, y_dim=1024, num_channels=3,
                   output_path=None, write_image=True):
  """Generate random `x_dim` by `y_dim`, optionally to `output_path`.

  Args:
    x_dim: int, the x dimension of generated raw image.
    y_dim: int, the x dimension of generated raw image.
    num_channels: int, number of channels in image.
    output_path: str, path to which to write image.
    write_image: bool, whether to write the image to output_path.

  Returns:
    numpy.array: The random `x_dim` by `y_dim` image (i.e. array).
  """

  rand_shape = (x_dim, y_dim, num_channels)

  if num_channels != 3:
    raise NotImplementedError("mock_raw_image for channels != 3 not yet "
                              "implemented.")

  img = np.random.random(rand_shape)
  img = np.uint8(img*255)

  if write_image:
    image_obj = allen_brain.PIL_Image()
    pil_img = image_obj.fromarray(img, mode="RGB")
    with tf.gfile.Open(output_path, "w") as f:
      pil_img.save(f, "jpeg")

  return img
Generate random `x_dim` by `y_dim`, optionally to `output_path`.

  Args:
    x_dim: int, the x dimension of generated raw image.
    y_dim: int, the x dimension of generated raw image.
    num_channels: int, number of channels in image.
    output_path: str, path to which to write image.
    write_image: bool, whether to write the image to output_path.

  Returns:
    numpy.array: The random `x_dim` by `y_dim` image (i.e. array).
  
tensor2tensor/data_generators/allen_brain_test.py