import numpy as np


def simple_normalization(x_data, axis=None):
    """
    Compute the softmax of each element along an axis of X.

    Parameters
    ----------
    x_data: ND-Array. Probably should be floats.
    theta (optional): float parameter, used as a multiplier
        prior to exponentiation. Default = 1.0
    axis: int (optional): axis to compute values along. Default is the
        first non-singleton axis.

    Returns an array the same size as X. The result will sum to 1
    along the specified axis.
    """

    # make X at least 2d
    y = np.atleast_2d(x_data)

    # find axis
    if axis is None:
        axis = next(j[0] for j in enumerate(y.shape) if j[1] > 1)

    # take the sum along the specified axis
    ax_sum = np.expand_dims(np.sum(y, axis=axis), axis)

    # finally: divide elementwise
    p = y / ax_sum

    # flatten if X was 1D
    if len(x_data.shape) == 1:
        p = p.flatten()

    return p

import numpy as np


def simple_normalization(x_data, axis=None):
    """
    Compute the softmax of each element along an axis of X.

    Parameters
    ----------
    x_data: ND-Array. Probably should be floats.
    theta (optional): float parameter, used as a multiplier
        prior to exponentiation. Default = 1.0
    axis: int (optional): axis to compute values along. Default is the
        first non-singleton axis.

    Returns an array the same size as X. The result will sum to 1
    along the specified axis.
    """

    # make X at least 2d
    y = np.atleast_2d(x_data)

    # find axis
    if axis is None:
        axis = next(j[0] for j in enumerate(y.shape) if j[1] > 1)

    # take the sum along the specified axis
    ax_sum = np.expand_dims(np.sum(y, axis=axis), axis)

    # finally: divide elementwise
    p = y / ax_sum

    # flatten if X was 1D
    if len(x_data.shape) == 1:
        p = p.flatten()

    return p

Compute the softmax of each element along an axis of X.      Parameters     ----------     x_data: ND-Array. Probably should be floats.     theta (optional): float parameter, used as a multiplier         prior to exponentiation. Default = 1.0     axis: int (optional): axis to compute values along. Default is the         first non-singleton axis.      Returns an array the same size as X. The result will sum to 1     along the specified axis. # make X at least 2d # find axis # take the sum along the specified axis # finally: divide elementwise # flatten if X was 1D