how to solve Notice: Undefined offset: 1?
This line of code will split arg(3) into an array of strings using _ as the delimiter.

  $tesr = explode('_', arg(3));


Assuming that in this case arg(3) is never empty, it is still possible that there are no underscores in arg(3), in which case you will have an array of 1 item.

Since arrays are zero based, this will give you something like

Array
(
    [0] =&gt; 'somestring'
)


In that case, your next piece of code

  if ($tesr[1] == $account_id) {


will throw the Undefined offset: 1 notice because there is no array element with the key 1.

If you want to safely use $tesr[1] you have to do something like

  if (isset($tesr[1]) &amp;&amp; $tesr[1] == $account_id) {


Additional unsolicited feedback:


Don't name your module 'custom'. Name it something more descriptive of its purpose. If it has many distinct purposes split it into multiple modules. It will be easier to maintain in future if you can easily tell what different modules do.
Always prefix your function names with the name of the module. _term_account() might clash with another module's function. Prefixing with your module's name helps avoid that.
You have global $base_url; and global $user; but then you never use them. 
Consider using a variable name that is more descriptive than $tesr, so you can easily tell what it means if you come back to the code in future.
Code is easier to work on if it uses consistent formatting standards. Check out Drupal's at https://www.drupal.org/docs/develop/standards