def add_role(var, role):
 roles = getattr(var.tag, 'roles', [])
 roles = [old_role for old_role in roles if (not isinstance(role, old_role.__class__))]
 if (not any((isinstance(old_role, role.__class__) for old_role in roles))):
  roles += [role]
 var.tag.roles = roles

def add_role ( var , role ) : roles = getattr ( var . tag , 'roles' , [ ] ) roles = [ old_role for old_role in roles if ( not isinstance ( role , old_role . __class__ ) ) ] if ( not any ( ( isinstance ( old_role , role . __class__ ) for old_role in roles ) ) ) : roles += [ role ] var . tag . roles = roles
add a role to a given theano variable .