code: def _get_layout(nplots, layout=None, layout_type="box"):
      if layout is not None:
          if not isinstance(layout, (tuple, list)) or len(layout) != 2:
              raise ValueError(
                  "Layout must be a tuple of (rows, columns)"
              )
  
          nrows, ncols = layout
  
          # Python 2 compat
          ceil_ = lambda x: int(ceil(x))
          if nrows == -1 and ncols > 0:
              layout = nrows, ncols = (
                  ceil_(float(nplots) / ncols),
                  ncols,
              )
          elif ncols == -1 and nrows > 0:
              layout = nrows, ncols = (
                  nrows,
                  ceil_(float(nplots) / nrows),
              )
          elif ncols <= 0 and nrows <= 0:
              msg = "At least one dimension of layout must be positive"
              raise ValueError(msg)
  
          if nrows * ncols < nplots:
              raise ValueError(
                  "Layout of {nrows}x{ncols} must be larger "
                  "than required size {nplots}".format(
                      nrows=nrows, ncols=ncols, nplots=nplots
                  )
              )
  
          return layout
  
      if layout_type == "single":
          return (1, 1)
      elif layout_type == "horizontal":
          return (1, nplots)
      elif layout_type == "vertical":
          return (nplots, 1)
  
      layouts = {1: (1, 1), 2: (1, 2), 3: (2, 2), 4: (2, 2)}
      try:
          return layouts[nplots]
      except KeyError:
          k = 1
          while k**2 < nplots:
              k += 1
  
          if (k - 1) * k >= nplots:
              return k, (k - 1)
          else:
              return k, k
  
file_path: catboost/contrib/python/pandas/py2/pandas/plotting/_tools.py
imports: from __future__ import division
  from math import ceil
  import warnings
  import numpy
  from pandas.compat import range
  from pandas.core.dtypes.common import is_list_like
  from pandas.core.dtypes.generic import ABCDataFrame, ABCIndexClass, ABCSeries
label_desc: Use image node_id 3 for calling a global function with example usage: _get_layout(nplots, layout, layout_type) and returns: layout, int,  int, layouts, int,  nplots, nplots,  int, k,  unknown, k,  k