code: def cooccurence(
      f, direction, output=None, symmetric=True, distance=1
  ):
      """
      cooccurence_matrix = cooccurence(f,
                              direction,
                              output={new matrix},
                              symmetric=True,
                              distance=1)
  
      Compute grey-level cooccurence matrix
  
      Parameters
      ----------
      f : ndarray of integer type
          The input image
      direction : integer
          Direction as index into (horizontal [default], diagonal
          [nw-se], vertical, diagonal [ne-sw])
      output : np.long 2 ndarray, optional
          preallocated result.
      symmetric : boolean, optional
          whether return a symmetric matrix (default: True)
      distance : integer, optional (default=1)
          Distance to the central pixel to consider.
  
      Returns
      -------
        cooccurence_matrix : cooccurence matrix
      """
      _verify_is_integer_type(f, "mahotas.cooccurence")
      if len(f.shape) == 2 and not (0 <= direction < 4):
          raise ValueError(
              "mahotas.texture.cooccurence: `direction` {0} is not in range(4).".format(
                  direction
              )
          )
      elif len(f.shape) == 3 and not (0 <= direction < 13):
          raise ValueError(
              "mahotas.texture.cooccurence: `direction` {0} is not in range(13).".format(
                  direction
              )
          )
      elif len(f.shape) not in (2, 3):
          raise ValueError(
              "mahotas.texture.cooccurence: cannot handle images of %s dimensions."
              % len(f.shape)
          )
  
      if output is None:
          mf = f.max()
          output = np.zeros((mf + 1, mf + 1), np.int32)
      else:
          assert (
              np.min(output.shape) >= f.max()
          ), "mahotas.texture.cooccurence: output is not large enough"
          assert (
              output.dtype == np.int32
          ), "mahotas.texture.cooccurence: output is not of type np.int32"
          output.fill(0)
  
      if len(f.shape) == 2:
          mask_size = 2 * distance + 1
          Bc = np.zeros((mask_size, mask_size), f.dtype)
          y, x = tuple(distance * i for i in _2d_deltas[direction])
          Bc[y + distance, x + distance] = 1
      else:
          mask_size = 2 * distance + 1
          Bc = np.zeros((mask_size, mask_size, mask_size), f.dtype)
          y, x, z = tuple(distance * i for i in _3d_deltas[direction])
          Bc[y + distance, x + distance, z + distance] = 1
      _texture.cooccurence(f, output, Bc, symmetric)
      return output
  
imports: import numpy
  from .None import _texture
  from ..internal import _verify_is_integer_type
label_desc: Use image node_id 4 for calling a global function with example usage: cooccurence(f, direction, output, symmetric, distance) and returns: output