# Path: disentanglement_lib/utils/resources.py
# def get_file(path):
# def get_files_in_folder(path):


import math
import numpy as np
import scipy
import tensorflow.compat.v1 as tf
import imageio
from disentanglement_lib.utils import resources
from PIL import Image
from six.moves import range
  while True:
    if num_elements > max_ratio * i * i:
      return best_i
    remainder = (i - num_elements % i) % i
    if remainder == 0:
      return i
    if remainder < best_remainder:
      best_remainder = remainder
      best_i = i
    i -= 1


def pad_around(image, padding_px=10, axis=None, value=None):
  """Adds a padding around each image."""
  # If axis is None, pad both the first and the second axis.
  if axis is None:
    image = pad_around(image, padding_px, axis=0, value=value)
    axis = 1
  padding_arr = padding_array(image, padding_px, axis, value=value)
  return np.concatenate([padding_arr, image, padding_arr], axis=axis)


def add_below(image, padding_px=10, value=None):
  """Adds a footer below."""
  if len(image.shape) == 2:
    image = np.expand_dims(image, -1)
  if image.shape[2] == 1:
    image = np.repeat(image, 3, 2)
  if image.shape[2] != 3:
    raise ValueError("Could not convert image to have three channels.")

# Path: disentanglement_lib/utils/resources.py
# def get_file(path):
# def get_files_in_folder(path):


# Path: disentanglement_lib/visualize/visualize_util.py
import math
import numpy as np
import scipy
import tensorflow.compat.v1 as tf
import imageio
from disentanglement_lib.utils import resources
from PIL import Image
from six.moves import range

  while True:
    if num_elements > max_ratio * i * i:
      return best_i
    remainder = (i - num_elements % i) % i
    if remainder == 0:
      return i
    if remainder < best_remainder:
      best_remainder = remainder
      best_i = i
    i -= 1


def pad_around(image, padding_px=10, axis=None, value=None):
  """Adds a padding around each image."""
  # If axis is None, pad both the first and the second axis.
  if axis is None:
    image = pad_around(image, padding_px, axis=0, value=value)
    axis = 1
  padding_arr = padding_array(image, padding_px, axis, value=value)
  return np.concatenate([padding_arr, image, padding_arr], axis=axis)


def add_below(image, padding_px=10, value=None):
  """Adds a footer below."""
  if len(image.shape) == 2:
    image = np.expand_dims(image, -1)
  if image.shape[2] == 1:
    image = np.repeat(image, 3, 2)
  if image.shape[2] != 3:
    raise ValueError("Could not convert image to have three channels.")

  with tf.gfile.Open(resources.get_file("disentanglement_lib.png"), "rb") as f: