code: def _check_and_set_attr(
      cls, field, name, value, result, invariant_errors
  ):
      check_type(cls, field, name, value)
      is_ok, error_code = field.invariant(value)
      if not is_ok:
          invariant_errors.append(error_code)
      else:
          setattr(result, name, value)
  
imports: from pyrsistent._checked_types import InvariantException, CheckedType, _restore_pickle, store_invariants
  from pyrsistent._field_common import set_fields, check_type, is_field_ignore_extra_complaint, PFIELD_NO_INITIAL, serialize, check_global_invariants
  from pyrsistent._transformations import transform
label_desc: Use image node_id 2 for calling a global function with example usage: _check_and_set_attr(cls, field, name, value, result, invariant_errors) without return types