code: def get_structuring_elem(A, Bc):
      """
      Bc_out = get_structuring_elem(A, Bc)
  
      Retrieve appropriate structuring element
  
      Parameters
      ----------
      A : ndarray
          array which will be operated on
      Bc : None, int, or array-like
          :None: Then Bc is taken to be 1
          :An integer: There are two associated semantics:
              connectivity
                ``Bc[y,x] = [[ is |y - 1| + |x - 1| <= Bc_i ]]``
              count
                ``Bc.sum() == Bc_i``
                This is the more traditional meaning (when one writes that
                "4-connected", this is what one has in mind).
  
            Fortunately, the value itself allows one to distinguish between the
            two semantics and, if used correctly, no ambiguity should ever occur.
          :An array: This should be of the same nr. of dimensions as A and will
              be passed through if of the right type. Otherwise, it will be cast.
  
      Returns
      -------
      Bc_out : ndarray
          Structuring element. This array will be of the same type as A,
          C-contiguous.
  
      """
      translate_sizes = {
          (2, 4): 1,
          (2, 8): 2,
          (3, 6): 1,
      }
      if Bc is None:
          Bc = 1
      elif type(Bc) == int and (len(A.shape), Bc) in translate_sizes:
          Bc = translate_sizes[len(A.shape), Bc]
      elif type(Bc) != int:
          if A.ndim != Bc.ndim:
              raise ValueError(
                  "morph.get_structuring_elem: Bc does not have the correct number of dimensions. [array has {} coordinates; Bc has {}.]".format(
                      A.ndim, Bc.ndim
                  )
              )
          Bc = np.asanyarray(Bc, A.dtype)
          if not Bc.flags.contiguous:
              return Bc.copy()
          return Bc
  
      # Special case typical case:
      if len(A.shape) == 2 and Bc == 1:
          return np.array(
              [[0, 1, 0], [1, 1, 1], [0, 1, 0]], dtype=A.dtype
          )
      max1 = Bc
      Bc = np.zeros((3,) * len(A.shape), dtype=A.dtype)
      centre = np.ones(len(A.shape))
      # This is pretty slow, but this should be a tiny array, so who cares
      for i in range(Bc.size):
          pos = np.unravel_index(i, Bc.shape)
          pos -= centre
          if np.sum(np.abs(pos)) <= max1:
              Bc.flat[i] = 1
      return Bc
  
imports: from __future__ import division
  import numpy
  from .internal import _get_output, _verify_is_integer_type, _check_2
  from .None import _morph
label_desc: Use image node_id 1 for calling a global function with example usage: get_structuring_elem(A, Bc) and returns: Bc, np, Bc, Bc