code: def downside_deviation(
      returns: Series, benchmark_rate: float = 0.0, tf: str = "years"
  ) -> float:
      """Downside Deviation for the Sortino ratio.
      Benchmark rate is assumed to be annualized. Adjusted according for the
      number of periods per year seen in the data.
  
      Args:
          close (pd.Series): Series of 'close's
          benchmark_rate (float): Benchmark Rate to use. Default: 0.0
          tf (str): Time Frame options: 'days', 'weeks', 'months', and 'years'.
              Default: 'years'
  
      >>> result = ta.downside_deviation(returns, benchmark_rate=0.0, tf="years")
      """
      # For both de-annualizing the benchmark rate and annualizing result
      returns = verify_series(returns)
      days_per_year = returns.shape[0] / total_time(returns, tf)
  
      adjusted_benchmark_rate = (
          (1 + benchmark_rate) ** (1 / days_per_year)
      ) - 1
  
      downside = adjusted_benchmark_rate - returns
      downside_sum_of_squares = (downside[downside > 0] ** 2).sum()
      downside_deviation = npSqrt(
          downside_sum_of_squares / (returns.shape[0] - 1)
      )
      return downside_deviation * npSqrt(days_per_year)
  
imports: from typing import Tuple
  from numpy import log
  from numpy import nan
  from numpy import sqrt
  from pandas import Series, Timedelta
  from ._core import verify_series
  from ._time import total_time
  from ._math import linear_regression, log_geometric_mean
  from pandas_ta import RATE
  from pandas_ta.performance import drawdown, log_return, percent_return
label_desc: Use image node_id 3 for calling a global function with example usage: downside_deviation(returns, benchmark_rate, tf) and returns: unknown