code: def _span_overlaps(
      source_start,
      source_limit,
      target_start,
      target_limit,
      contains,
      contained_by,
      partial_overlap,
  ):
      """Implementation of span_overlaps().
  
      If the inputs are ragged, then the source tensors must have exactly one
      batch dimension.  (I.e., `B=1` in the param descriptions below.)
  
      Args:
        source_start: `<int>[D1...DB, source_size]`
        source_limit: `<int>[D1...DB, source_size]`
        target_start: `<int>[D1...DB, target_size]`
        target_limit: `<int>[D1...DB, target_size]`
        contains: `bool`
        contained_by: `bool`
        partial_overlap: `bool`
  
      Returns:
        `<bool>[D1...DB, source_size, target_size]`
      """
      if isinstance(source_start, tensor.Tensor):
          # Reshape the source tensors to [D1...DB, source_size, 1] and the
          # target tensors to [D1...DB, 1, target_size], so we can use broadcasting.
          # In particular, elementwise_op(source_x, target_x) will have shape
          # [D1...DB, source_size, target_size].
          source_start = array_ops.expand_dims(source_start, -1)
          source_limit = array_ops.expand_dims(source_limit, -1)
          target_start = array_ops.expand_dims(target_start, -2)
          target_limit = array_ops.expand_dims(target_limit, -2)
  
          equal = math_ops.equal
          less_equal = math_ops.less_equal
          less = math_ops.less
          logical_and = math_ops.logical_and
          logical_or = math_ops.logical_or
  
      else:
          # Broadcast the source span indices to all have shape
          # [batch_size, (source_size), (target_size)].
          (
              source_start,
              source_limit,
          ) = _broadcast_ragged_sources_for_overlap(
              source_start, source_limit, target_start.row_splits
          )
          (
              target_start,
              target_limit,
          ) = _broadcast_ragged_targets_for_overlap(
              target_start, target_limit, source_start.row_splits
          )
  
          # Use map_flat_values to perform elementwise operations.
          equal = functools.partial(
              ragged_functional_ops.map_flat_values, math_ops.equal
          )
          less_equal = functools.partial(
              ragged_functional_ops.map_flat_values, math_ops.less_equal
          )
          less = functools.partial(
              ragged_functional_ops.map_flat_values, math_ops.less
          )
          logical_and = functools.partial(
              ragged_functional_ops.map_flat_values,
              math_ops.logical_and,
          )
          logical_or = functools.partial(
              ragged_functional_ops.map_flat_values, math_ops.logical_or
          )
  
      if partial_overlap:
          return logical_or(
              logical_and(
                  less_equal(source_start, target_start),
                  less(target_start, source_limit),
              ),
              logical_and(
                  less_equal(target_start, source_start),
                  less(source_start, target_limit),
              ),
          )
      elif contains and contained_by:
          return logical_or(
              logical_and(
                  less_equal(source_start, target_start),
                  less_equal(target_limit, source_limit),
              ),
              logical_and(
                  less_equal(target_start, source_start),
                  less_equal(source_limit, target_limit),
              ),
          )
      elif contains:
          return logical_and(
              less_equal(source_start, target_start),
              less_equal(target_limit, source_limit),
          )
      elif contained_by:
          return logical_and(
              less_equal(target_start, source_start),
              less_equal(source_limit, target_limit),
          )
      else:
          return logical_and(
              equal(target_start, source_start),
              equal(source_limit, target_limit),
          )
  
imports: from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  import functools
  from tensorflow.python.framework import dtypes
  from tensorflow.python.framework import ops
  from tensorflow.python.framework import tensor
  from tensorflow.python.ops import array_ops
  from tensorflow.python.ops import array_ops_stack
  from tensorflow.python.ops import check_ops
  from tensorflow.python.ops import math_ops
  from tensorflow.python.ops.ragged import ragged_functional_ops
  from tensorflow.python.ops.ragged import ragged_gather_ops
  from tensorflow.python.ops.ragged import ragged_math_ops
  from tensorflow.python.ops.ragged import ragged_tensor
  from tensorflow.python.ops.ragged import ragged_where_op
  from tensorflow.python.ops.ragged import segment_id_ops
label_desc: Use image node_id 3 for calling a global function with example usage: _span_overlaps(source_start, source_limit, target_start, target_limit, contains, contained_by, partial_overlap) and returns: logical_or, logical_or, logical_and, logical_and, logical_and