//  [python]
def get_model_activations_1d(dataset, model, cfg,
                             num_stimuli_types=1,
                             n_avg=100,
                             nbins=80,
                             model_pred_layer="g",
                             trajectory_seed=0,
                             eval_batch_size=None,
                             return_all=False):
    """Returns (num_pos_bins, num_units) model activations for a given arena size"""
    # create testing environment
    eval_cfg, pos_bins = set_cfg_from_vr1ddata(dataset=dataset,
                                               cfg=cfg,
                                               nbins=nbins,
                                               return_bins=True,
                                               meters_convert=True)

    print("Using this cfg to compute model activations: ", vars(eval_cfg))

    # get model activations
    _, _, g_dict, p, pos, inp = compute_ratemaps(model,
                                                 options=eval_cfg,
                                                 n_avg=n_avg,
                                                 trajectory_seed=trajectory_seed,
                                                 eval_batch_size=eval_batch_size,
                                                 return_all=True if ((return_all) or (
                                                             model_pred_layer not in ["g", "pc"])) else False)

    if return_all:
        # return all layers of an rnn simultaneously
        assert num_stimuli_types == 1
        assert isinstance(g_dict, dict)
        model_activations = {}
        for k, v in g_dict.items():
            curr_activations = s.binned_statistic(x=pos[:, 0],
                                                            values=v.T,
                                                            statistic='mean',
                                                            bins=pos_bins)[0]
            model_activations[k] = np.transpose(curr_activations, (1, 0))
    elif hasattr(model, model_pred_layer):
        if model_pred_layer == "pc":
            curr_values = p.T
        elif isinstance(g_dict, dict):
            curr_values = g_dict[model_pred_layer].T
        else:
            curr_values = g_dict.T

        model_activations = s.binned_statistic(x=pos[:, 0],
                                                         values=curr_values,
                                                         statistic='mean',
                                                         bins=pos_bins)[0]
        # put cells in last dimension (num_x_bins, num_grid_cells)
        model_activations = np.transpose(model_activations, (1, 0))
    elif model in ["cue_input", "velocity_input"]:
        if model == "cue_input":
            assert (hasattr(eval_cfg, "cue_input_only") and eval_cfg.cue_input_only)
        else:
            if hasattr(eval_cfg, "cue_input_only"):
                assert (eval_cfg.cue_input_only is False)

        model_activations = s.binned_statistic(x=pos[:, 0],
                                                         values=inp.T,
                                                         statistic='mean',
                                                         bins=pos_bins)[0]
        # (num_x_bins, input_dim)
        model_activations = np.transpose(model_activations, (1, 0))
    else:
        p_activations = s.binned_statistic(x=pos[:, 0],
                                                     values=p.T,
                                                     statistic='mean',
                                                     bins=pos_bins)[0]
        p_activations = np.transpose(p_activations, (1, 0))
        if model == "place_cells":
            model_activations = p_activations
        else:
            assert (hasattr(model, "transform"))
            # (num_x_bins, num_components)
            model_activations = model.transform(p_activations)
    return model_activations