code: def build_issue_manager(
      draw,
      num_samples_strategy,
      k_neighbors_strategy,
      with_issues=False,
      threshold=None,
  ):
      """Create a random knn_graph with the given number of samples and k neighbors.
      Run the NearDuplicateIssueManager on the knn_graph and return the issue manager.
      A threshold can be provided to control the number of issues for small graphs.
      A with_issues flag can be provided to control whether the issue manager should have issues.
      """
  
      if with_issues:
          knn_graph = draw(
              knn_graph_strategy(
                  num_samples=num_samples_strategy,
                  k_neighbors=k_neighbors_strategy,
              )
          )
      else:
          knn_graph = draw(
              knn_graph_strategy(
                  num_samples=num_samples_strategy,
                  k_neighbors=k_neighbors_strategy,
                  min_distance=0.1,
              )
          )
  
      lab = Datalab(data={})
      inputs = {"datalab": lab, "threshold": threshold}
      inputs = {k: v for k, v in inputs.items() if v is not None}
      issue_manager = NearDuplicateIssueManager(**inputs)
      issue_manager.find_issues(knn_graph=knn_graph)
      issues = issue_manager.issues["is_near_duplicate_issue"]
  
      if with_issues:
          assume(any(issues))
      else:
          assume(not any(issues))
      return issue_manager
  
imports: import numpy
  import pytest
  from hypothesis import HealthCheck, assume, given, settings, strategies
  from hypothesis.strategies import composite
  from hypothesis.extra.numpy import arrays
  from cleanlab import Datalab
  from cleanlab.datalab.internal.issue_manager.duplicate import NearDuplicateIssueManager
  from .conftest import knn_graph_strategy
label_desc: Use image node_id 2 for calling a global function with example usage: build_issue_manager(draw, num_samples_strategy, k_neighbors_strategy, with_issues, threshold) and returns: issue_manager