code: def _select_initial_step(
      func, t0, y0, order, rtol, atol, norm, f0=None
  ):
      """Empirically select a good initial step.
  
      The algorithm is described in [1]_.
  
      References
      ----------
      .. [1] E. Hairer, S. P. Norsett G. Wanner, "Solving Ordinary Differential
             Equations I: Nonstiff Problems", Sec. II.4, 2nd edition.
      """
  
      dtype = y0.dtype
      device = y0.device
      t_dtype = t0.dtype
      t0 = t0.to(t_dtype)
  
      if f0 is None:
          f0 = func(t0, y0)
  
      scale = atol + torch.abs(y0) * rtol
  
      d0 = norm(y0 / scale).abs()
      d1 = norm(f0 / scale).abs()
  
      if d0 < 1e-5 or d1 < 1e-5:
          h0 = torch.tensor(1e-6, dtype=dtype, device=device)
      else:
          h0 = 0.01 * d0 / d1
      h0 = h0.abs()
  
      y1 = y0 + h0 * f0
      f1 = func(t0 + h0, y1)
  
      d2 = torch.abs(norm((f1 - f0) / scale) / h0)
  
      if d1 <= 1e-15 and d2 <= 1e-15:
          h1 = torch.max(
              torch.tensor(1e-6, dtype=dtype, device=device), h0 * 1e-3
          )
      else:
          h1 = (0.01 / max(d1, d2)) ** (1.0 / float(order + 1))
      h1 = h1.abs()
  
      return torch.min(100 * h0, h1).to(t_dtype)
  
imports: from enum import Enum
  import math
  import numpy
  import torch
  import warnings
  from .event_handling import combine_event_functions
label_desc: Use image node_id 6 for calling a global function with example usage: _select_initial_step(func, t0, y0, order, rtol, atol, norm, f0) and returns: torch