code: def log_I1(orders: int, value: torch.Tensor, terms=250):
      r"""Compute first n log modified bessel function of first kind
      .. math ::
  
          \log(I_v(z)) = v*\log(z/2) + \log(\sum_{k=0}^\inf \exp\left[2*k*\log(z/2) - \sum_kk^k log(kk)
          - \lgamma(v + k + 1)\right])
  
      :param orders: orders of the log modified bessel function.
      :param value: values to compute modified bessel function for
      :param terms: truncation of summation
      :return: 0 to orders modified bessel function
      """
      orders = orders + 1
      if len(value.size()) == 0:
          vshape = torch.Size([1])
      else:
          vshape = value.shape
      value = value.reshape(-1, 1)
  
      k = torch.arange(terms, device=value.device)
      lgammas_all = torch.lgamma(
          torch.arange(1, terms + orders + 1, device=value.device)
      )
      assert lgammas_all.shape == (
          orders + terms,
      )  # lgamma(0) = inf => start from 1
  
      lvalues = torch.log(value / 2) * k.view(1, -1)
      assert lvalues.shape == (vshape.numel(), terms)
  
      lfactorials = lgammas_all[:terms]
      assert lfactorials.shape == (terms,)
  
      lgammas = lgammas_all.repeat(orders).view(orders, -1)
      assert lgammas.shape == (
          orders,
          terms + orders,
      )  # lgamma(0) = inf => start from 1
  
      indices = k[:orders].view(-1, 1) + k.view(1, -1)
      assert indices.shape == (orders, terms)
  
      seqs = (
          2 * lvalues[None, :, :]
          - lfactorials[None, None, :]
          - lgammas.gather(1, indices)[:, None, :]
      ).logsumexp(-1)
      assert seqs.shape == (orders, vshape.numel())
  
      i1s = lvalues[..., :orders].T + seqs
      assert i1s.shape == (orders, vshape.numel())
      return i1s.view(-1, *vshape)
  
file_path: pyro/pyro/ops/special.py
imports: import functools
  import math
  import operator
  import weakref
  from typing import Dict
  import numpy
  import torch
  from numpy.polynomial.hermite import hermgauss
label_desc: Use image node_id 4 for calling a global function with example usage: log_I1(orders, value, terms) and returns: i1s