code: def _fill_shape(x, n):
    
    if not isinstance(n, numbers.Integral) or n < 1:
      raise TypeError("n must be a positive integer")
  
    if (isinstance(x, numbers.Integral) or isinstance(x, tf.Dimension)) and x > 0:
      return (x,) * n
  
    try:
      if len(x) == n and all(v > 0 for v in x):
        return tuple(x)
    except TypeError:
      pass
  
    raise TypeError("x is {}, must be either a positive integer "
                    "or an iterable of positive integers of size {}"
                    .format(x, n))
docs: Converts a dimension to a tuple of dimensions of a given size.
  
    This is used to allow shorthand notation for various configuration parameters.
    A user can provide either, for example, `2` or `[2, 2]` as a kernel shape, and
    this function returns `(2, 2)` in both cases. Passing `[1, 2]` will return
    `(1, 2)`.
  
    Args:
      x: An integer, tf.Dimension, or an iterable of them.
      n: An integer, the size of the desired output list
  
    Returns:
      If `x` is an integer, a tuple of size `n` containing `n` copies of `x`.
      If `x` is an iterable of integers or tf.Dimension of size `n`, it returns
        `tuple(x)`.
  
    Raises:
      TypeError: If n is not a positive integer;
        or if x is neither integer nor an iterable of size n.