@staticmethod
def _compute_fans(shape):
    """Computes the number of input and output units for a weight shape.
        # Arguments
            shape: Integer shape tuple.
        # Returns
            A tuple of scalars, `(fan_in, fan_out)`.
        # Raises
            ValueError: in case of invalid shape size.
        """
    if len(shape) >= 2:
        fan_in = shape[-2]
        fan_out = shape[-1]
    else:
        raise ValueError('Invalid shape size.')
    return fan_in, fan_out
