code: def basictest(
      f,
      steps,
      sample_size,
      prefix="",
      allow_01=False,
      inputs=None,
      target_avg=0.5,
      target_std=None,
      mean_rtol=0.01,
      std_tol=0.01,
  ):
      if inputs is None:
          inputs = []
      dt = 0.0
      avg_var = 0.0
  
      for i in xrange(steps):
          t0 = time.time()
          ival = f(*inputs)
          assert ival.shape == sample_size
          dt += time.time() - t0
          ival = np.asarray(ival)
          if i == 0:
              mean = np.array(ival, copy=True)
              avg_var = np.mean((ival - target_avg) ** 2)
              min_ = ival.min()
              max_ = ival.max()
          else:
              alpha = 1.0 / (1 + i)
              mean = alpha * ival + (1 - alpha) * mean
              avg_var = (
                  alpha * np.mean((ival - target_avg) ** 2)
                  + (1 - alpha) * avg_var
              )
              min_ = min(min_, ival.min())
              max_ = max(max_, ival.max())
          if not allow_01:
              assert min_ > 0
              assert max_ < 1
  
      if hasattr(
          target_avg, "shape"
      ):  # looks if target_avg is an array
          diff = np.mean(abs(mean - target_avg))
          # print prefix, 'mean diff with mean', diff
          assert np.all(
              diff < mean_rtol * (1 + abs(target_avg))
          ), "bad mean? %s %s" % (mean, target_avg)
      else:
          # if target_avg is a scalar, then we can do the mean of
          # `mean` to get something more precise
          mean = np.mean(mean)
          # print prefix, 'mean', mean
          assert abs(mean - target_avg) < mean_rtol * (
              1 + abs(target_avg)
          ), "bad mean? %f %f" % (mean, target_avg)
  
      std = np.sqrt(avg_var)
      # print prefix, 'var', avg_var
      # print prefix, 'std', std
      if target_std is not None:
          assert abs(std - target_std) < std_tol * (
              1 + abs(target_std)
          ), "bad std? %f %f %f" % (std, target_std, std_tol)
  
imports: from __future__ import absolute_import, print_function, division
  import os
  import sys
  import time
  import unittest
  from nose.tools import assert_raises
  import numpy
  from six.moves import xrange
  import theano
  from theano import change_flags, config, tensor
  from theano.sandbox import rng_mrg
  from theano.sandbox.rng_mrg import MRG_RandomStreams
  from theano.tests import unittest_tools
  from theano.tests.unittest_tools import attr
label_desc: Use image node_id 6 for calling a global function with example usage: basictest(f, steps, sample_size, prefix, allow_01, inputs, target_avg, target_std, mean_rtol, std_tol) without return types