def _nested_variable(init, name=None, trainable=False):
 if (isinstance(init, list) or isinstance(init, tuple)):
  result = [_nested_variable(i, name, trainable) for i in init]
  if isinstance(init, tuple):
   return tuple(result)
  return result
 else:
  return tf.Variable(init, name=name, trainable=trainable)

def _nested_variable ( init , name = None , trainable = False ) : if ( isinstance ( init , list ) or isinstance ( init , tuple ) ) : result = [ _nested_variable ( i , name , trainable ) for i in init ] if isinstance ( init , tuple ) : return tuple ( result ) return result else : return tf . Variable ( init , name = name , trainable = trainable )
returns a nested collection of tensorflow variables .