code: def partially_pooled_with_logit(at_bats, hits):
      r"""
      Number of hits has a Binomial distribution with a logit link function.
      The logits $\alpha$ for each player is normally distributed with the
      mean and scale parameters sharing a common prior.
  
      :param (torch.Tensor) at_bats: Number of at bats for each player.
      :param (torch.Tensor) hits: Number of hits for the given at bats.
      :return: Number of hits predicted by the model.
      """
      num_players = at_bats.shape[0]
      loc = pyro.sample(
          "loc",
          Normal(scalar_like(at_bats, -1), scalar_like(at_bats, 1)),
      )
      scale = pyro.sample(
          "scale", HalfCauchy(scale=scalar_like(at_bats, 1))
      )
      with pyro.plate("num_players", num_players):
          alpha = pyro.sample("alpha", Normal(loc, scale))
          return pyro.sample(
              "obs", Binomial(at_bats, logits=alpha), obs=hits
          )
  
file_path: pyro/examples/baseball.py
imports: import argparse
  import logging
  import math
  import pandas
  import torch
  import pyro
  from pyro.distributions import Beta, Binomial, HalfCauchy, Normal, Pareto, Uniform
  from pyro.distributions.util import scalar_like
  from pyro.infer import MCMC, NUTS, Predictive
  from pyro.infer.mcmc.util import initialize_model, summary
  from pyro.util import ignore_experimental_warning
label_desc: Use image node_id 4 for calling a global function with example usage: partially_pooled_with_logit(at_bats, hits) and returns: pyro