@contextlib.contextmanager
def batch_normalization(*bricks):
 from blocks.bricks import BatchNormalization
 bn = find_bricks(bricks, (lambda b: isinstance(b, BatchNormalization)))
 try:
  for brick in bn:
   brick.__enter__()
  (yield)
 finally:
  for brick in bn[::(-1)]:
   brick.__exit__()

@ contextlib . contextmanager def batch_normalization ( * bricks ) : from blocks . bricks import BatchNormalization bn = find_bricks ( bricks , ( lambda b : isinstance ( b , BatchNormalization ) ) ) try : for brick in bn : brick . __enter__ ( ) ( yield ) finally : for brick in bn [ : : ( - 1 ) ] : brick . __exit__ ( )
apply batch normalization on x given mean .