code: def ndarray_to_block(
      ndarray: np.ndarray, ctx: DataContext
  ) -> "Block":
      from ray.data.block import BlockAccessor, BlockExecStats
  
      DataContext._set_current(ctx)
  
      stats = BlockExecStats.builder()
      block = BlockAccessor.batch_to_block({"data": ndarray})
      metadata = BlockAccessor.for_block(block).get_metadata(
          input_files=None, exec_stats=stats.build()
      )
      return block, metadata
  
imports: import importlib
  import logging
  import os
  import pathlib
  import random
  import sys
  import threading
  import time
  import urllib.parse
  from collections import deque
  from types import ModuleType
  from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, Iterator, List, Optional, Tuple, TypeVar, Union
  import numpy
  import ray
  from ray._private.utils import _get_pyarrow_version
  from ray.data._internal.arrow_ops.transform_pyarrow import unify_schemas
  from ray.data.context import WARN_PREFIX, DataContext
label_desc: Use image node_id 22 for calling a global function with example usage: ndarray_to_block(ndarray, ctx) and returns: block,  metadata