code: def _adjust_to_origin(arg, origin, unit):
      """
      Helper function for to_datetime.
      Adjust input argument to the specified origin
  
      Parameters
      ----------
      arg : list, tuple, ndarray, Series, Index
          date to be adjusted
      origin : 'julian' or Timestamp
          origin offset for the arg
      unit : str
          passed unit from to_datetime, must be 'D'
  
      Returns
      -------
      ndarray or scalar of adjusted date(s)
      """
      if origin == "julian":
          original = arg
          j0 = Timestamp(0).to_julian_date()
          if unit != "D":
              raise ValueError("unit must be 'D' for origin='julian'")
          try:
              arg = arg - j0
          except TypeError as err:
              raise ValueError(
                  "incompatible 'arg' type for given 'origin'='julian'"
              ) from err
  
          # preemptively check this for a nice range
          j_max = Timestamp.max.to_julian_date() - j0
          j_min = Timestamp.min.to_julian_date() - j0
          if np.any(arg > j_max) or np.any(arg < j_min):
              raise OutOfBoundsDatetime(
                  f"{original} is Out of Bounds for origin='julian'"
              )
      else:
          # arg must be numeric
          if not (
              (is_scalar(arg) and (is_integer(arg) or is_float(arg)))
              or is_numeric_dtype(np.asarray(arg))
          ):
              raise ValueError(
                  f"'{arg}' is not compatible with origin='{origin}'; "
                  "it must be numeric with a unit specified"
              )
  
          # we are going to offset back to unix / epoch time
          try:
              offset = Timestamp(origin, unit=unit)
          except OutOfBoundsDatetime as err:
              raise OutOfBoundsDatetime(
                  f"origin {origin} is Out of Bounds"
              ) from err
          except ValueError as err:
              raise ValueError(
                  f"origin {origin} cannot be converted to a Timestamp"
              ) from err
  
          if offset.tz is not None:
              raise ValueError(
                  f"origin offset {offset} must be tz-naive"
              )
          td_offset = offset - Timestamp(0)
  
          # convert the offset to the unit of the arg
          # this should be lossless in terms of precision
          ioffset = td_offset // Timedelta(1, unit=unit)
  
          # scalars & ndarray-like can handle the addition
          if is_list_like(arg) and not isinstance(
              arg, (ABCSeries, Index, np.ndarray)
          ):
              arg = np.asarray(arg)
          arg = arg + ioffset
      return arg
  
imports: from __future__ import annotations
  from collections import abc
  from datetime import datetime
  from functools import partial
  from itertools import islice
  from typing import TYPE_CHECKING, Callable, Hashable, List, Tuple, TypedDict, Union, cast, overload
  import warnings
  import numpy
  from pandas._libs import lib, tslib
  from pandas._libs.tslibs import OutOfBoundsDatetime, Timedelta, Timestamp, astype_overflowsafe, get_unit_from_dtype, iNaT, is_supported_unit, nat_strings, parsing, timezones
  from pandas._libs.tslibs.conversion import precision_from_unit
  from pandas._libs.tslibs.parsing import DateParseError, guess_datetime_format
  from pandas._libs.tslibs.strptime import array_strptime
  from pandas._typing import AnyArrayLike, ArrayLike, DateTimeErrorChoices, npt
  from pandas.util._exceptions import find_stack_level
  from pandas.core.dtypes.common import ensure_object, is_datetime64_dtype, is_datetime64tz_dtype, is_float, is_integer, is_integer_dtype, is_list_like, is_numeric_dtype, is_scalar
  from pandas.core.dtypes.generic import ABCDataFrame, ABCSeries
  from pandas.core.dtypes.missing import notna
  from pandas.arrays import DatetimeArray, IntegerArray, PandasArray
  from pandas.core import algorithms
  from pandas.core.algorithms import unique
  from pandas.core.arrays.base import ExtensionArray
  from pandas.core.arrays.datetimes import maybe_convert_dtype, objects_to_datetime64ns, tz_to_dtype
  from pandas.core.construction import extract_array
  from pandas.core.indexes.base import Index
  from pandas.core.indexes.datetimes import DatetimeIndex
label_desc: Use image node_id 10 for calling a global function with example usage: _adjust_to_origin(arg, origin, unit) and returns: arg