code: def calc_end_idx(profile_len, idx, step_size, idx_diff):
      return np.min(
          [
              profile_len - 1,
              idx + step_size - 1,
              profile_len - idx_diff - 1,
          ]
      )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  from __future__ import unicode_literals
  import math
  import time
  import warnings
  import numpy
label_desc: Use image node_id 13 for calling a global function with example usage: calc_end_idx(profile_len, idx, step_size, idx_diff) and returns: np