code: def _get_binary_erosion_kernel(
      w_shape,
      int_type,
      offsets,
      center_is_true,
      border_value,
      invert,
      masked,
      all_weights_nonzero,
  ):
      if invert:
          border_value = int(not border_value)
          true_val = 0
          false_val = 1
      else:
          true_val = 1
          false_val = 0
  
      if masked:
          pre = """
              bool mv = (bool)mask[i];
              bool _in = (bool)x[i];
              if (!mv) {{
                  y = cast<Y>(_in);
                  return;
              }} else if ({center_is_true} && _in == {false_val}) {{
                  y = cast<Y>(_in);
                  return;
              }}""".format(
              center_is_true=int(center_is_true), false_val=false_val
          )
      else:
          pre = """
              bool _in = (bool)x[i];
              if ({center_is_true} && _in == {false_val}) {{
                  y = cast<Y>(_in);
                  return;
              }}""".format(
              center_is_true=int(center_is_true), false_val=false_val
          )
      pre = (
          pre
          + """
              y = cast<Y>({true_val});""".format(
              true_val=true_val
          )
      )
  
      # {{{{ required because format is called again within _generate_nd_kernel
      found = """
          if ({{cond}}) {{{{
              if (!{border_value}) {{{{
                  y = cast<Y>({false_val});
                  return;
              }}}}
          }}}} else {{{{
              bool nn = {{value}} ? {true_val} : {false_val};
              if (!nn) {{{{
                  y = cast<Y>({false_val});
                  return;
              }}}}
          }}}}""".format(
          true_val=int(true_val),
          false_val=int(false_val),
          border_value=int(border_value),
      )
  
      name = "binary_erosion"
      if false_val:
          name += "_invert"
      return _filters_core._generate_nd_kernel(
          name,
          pre,
          found,
          "",
          "constant",
          w_shape,
          int_type,
          offsets,
          0,
          ctype="Y",
          has_weights=True,
          has_structure=False,
          has_mask=masked,
          binary_morphology=True,
          all_weights_nonzero=all_weights_nonzero,
      )
  
imports: import operator
  import warnings
  import numpy
  import cupy
  from cupy import _core
  from cupyx.scipy.ndimage import _filters_core
  from cupyx.scipy.ndimage import _util
  from cupyx.scipy.ndimage import _filters
label_desc: Use image node_id 1 for calling a global function with example usage: _get_binary_erosion_kernel(w_shape, int_type, offsets, center_is_true, border_value, invert, masked, all_weights_nonzero) and returns: _filters_core