code: def compute_histogram(
      df: pl.dataframe.frame.DataFrame,
      column_name: str,
      column_type: ColumnType,
      min_value: Union[int, float],
      max_value: Union[int, float],
      n_bins: int,
      n_samples: int,
  ) -> Histogram:
      """
      Compute histogram over numerical (int and float) data using `polars`.
      `polars` histogram implementation uses left half-open intervals in bins, while more standard approach
      (implemented in `numpy`, for example) would be to use right half-open intervals
      (except for the last bin, which is closed to include the maximum value).
      In order to be aligned with this, this function first multiplies all values in column and bin edges by -1,
      computes histogram with `polars` using these inverted numbers, and then reverses everything back.
      """
  
      logging.debug(f"Compute histogram for {column_name=}")
      bin_edges = generate_bins(
          min_value=min_value,
          max_value=max_value,
          column_name=column_name,
          column_type=column_type,
          n_bins=n_bins,
      )
      if (
          len(bin_edges) == 2
      ):  # possible if min == max (=data has only one value)
          if bin_edges[0] != bin_edges[1]:
              raise StatisticsComputationError(
                  f"Got unexpected result during histogram computation for {column_name=}, {column_type=}: "
                  f" len({bin_edges=}) is 2 but {bin_edges[0]=} != {bin_edges[1]=}. "
              )
          hist = [int(df[column_name].is_not_null().sum())]
      elif len(bin_edges) > 2:
          bins_edges_reverted = [-1 * b for b in bin_edges[::-1]]
          hist_df_reverted = df.with_columns(
              pl.col(column_name).mul(-1).alias("reverse")
          )["reverse"].hist(bins=bins_edges_reverted)
          hist_reverted = (
              hist_df_reverted["reverse_count"].cast(int).to_list()
          )
          hist = hist_reverted[::-1]
          hist = (
              [hist[0] + hist[1]] + hist[2:-2] + [hist[-2] + hist[-1]]
          )
      else:
          raise StatisticsComputationError(
              f"Got unexpected result during histogram computation for {column_name=}, {column_type=}: "
              f" unexpected {bin_edges=}"
          )
      logging.debug(f"{hist=} {bin_edges=}")
  
      if len(hist) != len(bin_edges) - 1:
          raise StatisticsComputationError(
              f"Got unexpected result during histogram computation for {column_name=}, {column_type=}: "
              f" number of bins in hist counts and bin edges don't match {hist=}, {bin_edges=}"
          )
      if sum(hist) != n_samples:
          raise StatisticsComputationError(
              f"Got unexpected result during histogram computation for {column_name=}, {column_type=}: "
              f" hist counts sum and number of non-null samples don't match, histogram sum={sum(hist)}, {n_samples=}"
          )
  
      return Histogram(
          hist=hist,
          bin_edges=np.round(bin_edges, DECIMALS).tolist()
          if column_type is column_type.FLOAT
          else bin_edges,
      )
  
imports: import enum
  import logging
  import os
  from pathlib import Path
  from typing import Any, Optional, TypedDict, Union
  import numpy
  import polars
  from datasets import ClassLabel, Features
  from huggingface_hub import hf_hub_download
  from libcommon.exceptions import CacheDirectoryNotInitializedError, NoSupportedFeaturesError, ParquetResponseEmptyError, PreviousStepFormatError, SplitWithTooBigParquetError, StatisticsComputationError
  from libcommon.simple_cache import get_previous_step_or_raise
  from libcommon.storage import StrPath
  from libcommon.utils import JobInfo
  from requests.exceptions import ReadTimeout
  from tqdm import tqdm
  from worker.config import AppConfig, DescriptiveStatisticsConfig
  from worker.dtos import CompleteJobResult
  from worker.job_runners.split.split_job_runner import SplitJobRunnerWithCache
  from worker.utils import HF_HUB_HTTP_ERROR_RETRY_SLEEPS, retry
label_desc: Use image node_id 2 for calling a global function with example usage: compute_histogram(df, column_name, column_type, min_value, max_value, n_bins, n_samples) and returns: Histogram