def _nested_assign(ref, value):
 if (isinstance(ref, list) or isinstance(ref, tuple)):
  if (len(ref) != len(value)):
   raise ValueError('ref and value have different lengths.')
  result = [_nested_assign(r, v) for (r, v) in zip(ref, value)]
  if isinstance(ref, tuple):
   return tuple(result)
  return result
 else:
  return tf.assign(ref, value)

def _nested_assign ( ref , value ) : if ( isinstance ( ref , list ) or isinstance ( ref , tuple ) ) : if ( len ( ref ) != len ( value ) ) : raise ValueError ( 'ref and value have different lengths.' ) result = [ _nested_assign ( r , v ) for ( r , v ) in zip ( ref , value ) ] if isinstance ( ref , tuple ) : return tuple ( result ) return result else : return tf . assign ( ref , value )
returns a nested collection of tensorflow assign operations .