human
I am working on the file "SYDE 556 Lecture 9 Action Selection.ipynb".
The first task is:
There's also another way to do this
A special case for forcing a function to go to zero when a particular group of neurons is active
Can you write Python code for it?

Give me a the Python code you requested?
assistant
#Here is the Python code you requested.

%pylab inline
import nengo
from nengo.dists import Uniform

model = nengo.Network('Creature')

with model:
    stim = nengo.Node([0,0], label='stim')
    command = nengo.Ensemble(100, dimensions=2, label='command')
    motor = nengo.Ensemble(100, dimensions=2, label='motor')
    position = nengo.Ensemble(1000, dimensions=2, label='position')
    scared_direction = nengo.Ensemble(100, dimensions=2, label='scared direction')

    def negative(x):
        return -x[0], -x[1]

    nengo.Connection(position, scared_direction, function=negative)
    nengo.Connection(position, position, synapse=.05)
    
    def rescale(x):
        return x[0]*0.1, x[1]*0.1
    nengo.Connection(motor, position, function=rescale)
    nengo.Connection(stim, command)
    
    D=4
    Q_input = nengo.Node([0,0,0,0], label='select')
    Qs = nengo.networks.EnsembleArray(50, n_ensembles=4)
    nengo.Connection(Q_input, Qs.input)
    Action = nengo.networks.EnsembleArray(50, n_ensembles=D, intercepts=Uniform(0.2,1), 
                             encoders=Uniform(1,1))
    bias = nengo.Node([1]*D)
    nengo.Connection(bias, Action.input)
    nengo.Connection(Action.output, Action.input, transform=(np.eye(D)-1), synapse=0.008)    

    basal_ganglia = nengo.networks.BasalGanglia(dimensions=D)    
    
    nengo.Connection(Qs.output, basal_ganglia.input, synapse=None)
    nengo.Connection(basal_ganglia.output, Action.input)

    do_command = nengo.Ensemble(300, dimensions=2, label='do command')
    nengo.Connection(command, do_command)
    nengo.Connection(Action.output[1], do_command.neurons, transform=-np.ones([300,1]))
    nengo.Connection(do_command, motor)
    
    do_scared = nengo.Ensemble(300, dimensions=2, label='do scared')
    nengo.Connection(scared_direction, do_scared)
    nengo.Connection(Action.output[0], do_scared.neurons, transform=-np.ones([300,1]))
    nengo.Connection(do_scared, motor)    

from nengo_gui.ipython import IPythonViz
IPythonViz(model, "configs/bg_creature2.py.cfg")