Explain the rules for an act done in good faith for the benefit of a child or insane person, by or by consent of a guardian as outlined in Indian Penal Code (IPC 1860) Section 89: Act done in good faith for benefit of child or insane person, by or by consent of guardian and their relevant Bharatiya Nyaya Sanhita 2023 (BNS 2023) code reference.

{'IPC Section': '89', 'IPC Heading': 'Act done in good faith for benefit of child or insane person, by or by consent of guardian', 'IPC Descriptions': " Indian Penal Code, 1860 
89. Act done
in good faith for benefit of child or insane person, by or by consent of
guardian 
Nothing which is done
in good faith for the benefit of a person under twelve years of age, or of
unsound mind, by or by consent, either express or implied, of the guardian or
other person having lawful charge of that person, is an offence by reason of
any harm which it may cause, or be intended by the doer to cause or be known by
the doer to be likely to cause to that person:
ProvisosProvided
First  That this
exception shall not extend to the intentional causing of death, or to the
attempting to cause death;
Secondly That this
exception shall not extend to the doing of anything which the person doing it
knows to be likely to cause death, for any purpose other than the preventing of
death or grievous hurt, or the curing of any grievous disease or infirmity;
Thirdly  That
this exception shall not extend to the voluntary causing of grievous hurt, or
to the attempting to cause grievous hurt, unless it be for the purpose of
preventing death or grievous hurt, or the curing of any grievous disease or
infirmity;
Fourthly That this
exception shall not extend to the abetment of any offence, to the committing of
which offence it would not extend.
Illustration
A, in good faith, for
his child's benefit without his child's consent, has his child cut for the
stone by a surgeon, knowing it to be likely that the operation will cause the
child's death, but not intending to cause the child's death. A is within the
exception in as much as his object was the cure of the child.", 'BNS Section': '27', 'BNS Heading': 'Act done in good faith for benefit of child or person of unsound mind, by, or by consent of guardian', 'BNS description': "The Bharatiya Nyaya Sanhita, 2023
27. Act done in good faith for benefit of child or person of unsound mind, by, or by consent of guardian.
Nothing which is done in good faith for the benefit of a person under twelve years of age, or person of unsound mind, by, or by consent, either express or implied, of the guardian or other person having lawful charge of that person, is an offence by reason of any harm which it may cause, or be intended by the doer to cause or be known by the doer to be likely to cause to that person:
Provided that this exception shall not extend to
(a) the intentional causing of death, or to the attempting to cause death;
(b) the doing of anything which the person doing it knows to be likely to cause death, for any purpose other than the preventing of death or grievous hurt, or the curing of any grievous disease or infirmity;
(c) the voluntary causing of grievous hurt, or to the attempting to cause grievous hurt, unless it be for the purpose of preventing death or grievous hurt, or the curing of any grievous disease or infirmity;
(d) the abetment of any offence, to the committing of which offence it would not extend.
Illustration.
A, in good faith, for his child's benefit without his child's consent, has his child cut for the stone by a surgeon knowing it to be likely that the operation will cause the child's death, but not intending to cause the child's death. A is within the exception, in as much as his object was the cure of the child."}